Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
469 stars 52 forks source link

Release 1.11.x branch #5

Closed Ramblurr closed 7 years ago

Ramblurr commented 7 years ago

In the latest release 1.10.14 JpaEntityGraphRepositoryFactoryBean is missing a constructor which is required due to the JpaRepositoryFactoryBean base class.

On the master branch it appears fixed, do you plan to release a fixed version soon?

reda-alaoui commented 7 years ago

Hello @Ramblurr,

Can you tell me which exact version of Spring Data you are using?

Ramblurr commented 7 years ago

Thanks @reda-alaoui.

I'm on the Ingalls-RELEASE release train.

So this would be: spring-data-jpa 1.11.0.RELEASE

reda-alaoui commented 7 years ago

As mentioned in the doc, spring-data-jpa-entity-graph versions follow spring-data versions.

This means that spring-data-jpa-entity-graph 1.10.x is only expected to work with spring-data 1.10.y.

Therefore, you must use spring-data-jpa-entity-graph 1.11.x with spring-data-jpa 1.11.0.RELEASE.

But there is currently no release for branch spring-data-jpa-entity-graph 1.11.x. I am going to perform it by the end of the day, so you can use it with spring-data-jpa 1.11.0.RELEASE.

Ramblurr commented 7 years ago

Thanks @reda-alaoui! I've checked out and compiled the master branch and now I have it working locally. Looking forward to the 1.11.x release.

Ramblurr commented 7 years ago

Any plans to support Projections with the querydsl predicate methods?

I'd love to be able to return Projection DTOs, but querying with a Predicate and EG.

reda-alaoui commented 7 years ago

1.11.00 has just been released. It will be available in the next hour.

reda-alaoui commented 7 years ago

spring-data-jpa projection query select part is built by scanning each attribute of the expected returned type.

i.e.:

public class Product {
  private long id;
  private String name; 
  private Brand brand;
}
public interface ProductName {
  String getName();
}
public interface ProductRepository{
  ProductName findProductNameByName(String name);
}

In this example, the following query would be built by spring-data-jpa:

select name from product where name = $name

Therefore, I don't see what would be the interest of mixing projection DTOs with EntityGraphs.

I am closing this ticket to mark it as resolved, but feel free to explain what you would be expecting precisely :)

reda-alaoui commented 7 years ago

In JpaQueryCreator:

if (returnedType.needsCustomConstruction()) {

  List<Selection<?>> selections = new ArrayList<Selection<?>>();

  for (String property : returnedType.getInputProperties()) {

    PropertyPath path = PropertyPath.from(property, returnedType.getDomainType());
    selections.add(toExpressionRecursively(root, path).alias(property));
  }
  query = query.multiselect(selections);

}