Git Product home page Git Product logo

spring-data-jpa-entity-graph's Introduction

Build Status Maven Central

Spring Data JPA EntityGraph

Spring Data JPA only supports EntityGraph through annotations.
Thus, for a repository method, you must select at most one EntityGraph before compilation.
This prevents you from choosing the best EntityGraph considering the runtime context πŸ’”

Spring Data JPA EntityGraph allows you to choose EntityGraph at runtime! This choice is elegantly made by passing EntityGraph, as an argument, to any Spring Data JPA repository method 😍

Quick start

  1. Select the correct version from the compatibility matrix

  2. In addition to Spring Data JPA, add Spring Data JPA EntityGraph dependency :

    <dependency>
      <groupId>com.cosium.spring.data</groupId>
      <artifactId>spring-data-jpa-entity-graph</artifactId>
      <version>${spring-data-jpa-entity-graph.version}</version>
    </dependency>
  3. Set the repository factory bean class to EntityGraphJpaRepositoryFactoryBean :

    @SpringBootApplication
    @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class)
    public class App {
        //...
    }

2.x to 3.x breaking changes

  • Moved from Java 8 to 17 as the source language
  • javax.persistence replaced by jakarta.persistence
  • com.cosium.spring.data.jpa.entity.graph.domain classes (deprecated in 2.7.x) have been removed in favor of com.cosium.spring.data.jpa.entity.graph.domain2
  • Default EntityGraph by name pattern feature (deprecated in 2.7.x) has been removed. *.default named EntityGraph are not considered as default EntityGraph anymore. Please read default EntityGraph to use the new Default EntityGraph feature instead.

Usage

On custom repository methods

If you want to define a custom repository method accepting an EntityGraph, just do itβ„’.

For example, given an entity having attribute named label of type String, you could declare and use a repository like this:

interface MyRepository extends Repository<MyEntity, Long> {
	Optional<MyEntity> findByLabel(String label, EntityGraph entityGraph);
}
myRepository.findByLabel("foo", NamedEntityGraph.loading("bar"));

On pre-defined repository methods

Spring Data JPA EntityGraph provides repository interfaces extending Spring Data JPA. For each Spring Data JPA pre-defined method, the provided interfaces overload the method with EntityGraph as an additional argument.

For example, Spring Data JPA CrudRepository defines method Optional<T> findById(ID id). This method is overloaded by Spring Data JPA EntityGraph EntityGraphCrudRepository as Optional<T> findById(ID id, EntityGraph entityGraph).

To be able to use these overloaded methods, you must extend one of Spring Data JPA EntityGraph provided repository interfaces.

The following matrix describes the mapping between Spring Data JPA and Spring Data JPA EntityGraph :

Spring Data JPA Spring Data JPA EntityGraph
JpaRepository EntityGraphJpaRepository
JpaSpecificationExecutor EntityGraphJpaSpecificationExecutor
QuerydslPredicateExecutor EntityGraphQuerydslPredicateExecutor
CrudRepository EntityGraphCrudRepository
PagingAndSortingRepository EntityGraphPagingAndSortingRepository
QueryByExampleExecutor EntityGraphQueryByExampleExecutor

For example, if you wanted to use Optional<T> findById(ID id, EntityGraph entityGraph), you could declare and use your repository like this:

interface MyRepository extends EntityGraphCrudRepository<MyEntity, Long> {
}
myRepository.findById(1L, NamedEntityGraph.loading("foo"));

EntityGraph provided implementations

DynamicEntityGraph

DynamicEntityGraph class allows you to create on-the-fly EntityGraph by defining their attribute paths. This is similar to Spring's ad-hoc attribute paths.

For example, let's consider the following entities :

@Entity
class Maker {
   //...
   @OneToOne(fetch = FetchType.LAZY)
   private Address address;
   //...
}
@Entity
class Product {
    @Id
    private long id = 0;
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    private Brand brand;
    @ManyToOne(fetch = FetchType.LAZY)
    private Maker maker;
    //...
}	

You could declare the following repository :

public interface MyRepository extends Repository<Product, Long> {
    List<Product> findByName(String name, EntityGraph entityGraph);
}

Then perform the findByName using ad-hoc product(brand, maker(address)) EntityGraph :

myRepository.findById(1L, DynamicEntityGraph.loading().addPath("brand").addPath("maker", "address").build());

NamedEntityGraph

NamedEntityGraph class allows you to reference an EntityGraph by its name. Such EntityGraph must have beforehand been registered through EntityManager#createEntityGraph(String graphName) or declared using @NamedEntityGraph annotation.

For example, let's consider the following entity :

@NamedEntityGraphs(value = {
    @NamedEntityGraph(name = "productBrand", attributeNodes = {
        @NamedAttributeNode("brand")
    })
})
@Entity
public class Product {
    @Id
    private long id = 0;
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    private Brand brand;
    //...
}	

You could declare the following repository :

public interface MyRepository extends Repository<Product, Long> {
    List<Product> findByName(String name, EntityGraph entityGraph);
}

Then perform the findByName query using productBrand named EntityGraph like this :

myRepository.findByName("foo", NamedEntityGraph.loading("productBrand"));

Type safe EntityGraph

Composing entity graphs by hand can be tedious and error-prone. Wouldn't it be great to benefit from autocompletion and strong type checking while composing your entity graph?

Spring Data JPA EntityGraph Generator has you covered.

This annotation processor makes use of the JPA metamodel information (part of JPA specification) generated by the tool of your choice (e.g. hibernate-jpamodelgen) to generate EntityGraph composers allowing you to safely and easily compose EntityGraph at runtime.

You need to add:

  • A JPA metamodel information generator. hibernate-jpamodelgen is great and should be compatible with any JPA ORM.
  • The entity graph generator annotation processor dependency.

Your pom.xml should look like this:

<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
            <annotationProcessorPaths>
               <path>
                  <groupId>org.hibernate.orm</groupId>
                  <artifactId>hibernate-jpamodelgen</artifactId>
                  <version>${hibernate-jpamodelgen.version}</version>
               </path>
               <path>
                  <groupId>com.cosium.spring.data</groupId>
                  <artifactId>spring-data-jpa-entity-graph-generator</artifactId>
                  <version>${spring-data-jpa-entity-graph.version}</version>
               </path>
            </annotationProcessorPaths>
         </configuration>
      </plugin>
   </plugins>
</build>

After compiling your project, you should find XEntityGraph classes where X is the name of your Entity.

For example, let's consider the following entity :

@Entity
public class Product {
    @Id
    private long id = 0;
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    private Brand brand;
    //...
}	

You could declare the following repository :

public interface MyRepository extends Repository<Product, Long> {
    List<Product> findByName(String name, EntityGraph entityGraph);
}

spring-data-jpa-entity-graph-generator will detect Product and generate in return ProductEntityGraph class. You could then perform the findByName query using product(brand, maker(address)) EntityGraph like this :

productRepository.findById(1L, ProductEntityGraph
                               .____()
                               .brand()
                               .____
                               .maker()
                               .address()
                               .____
                               .____());

Repository default EntityGraph

You can declare at most one default EntityGraph per repository by overriding EntityGraphRepository#defaultEntityGraph method.

Calling any repository query method - custom or pre-defined - without EntityGraph or with an EntityGraph#NOOP equivalent will lead to the default EntityGraph usage. Otherwise, the EntityGraph passed as query method argument will always have priority.

You could declare a repository as follows :

interface MyRepository extends EntityGraphCrudRepository<MyEntity, Long> {
  @Override
  default Optional<EntityGraph> defaultEntityGraph() {
    return NamedEntityGraph.loading("foo").execute(Optional::of);
  } 
  
  List<MyEntity> findByName(String name);
  List<MyEntity> findByName(String name, EntityGraph entityGraph);
}

The following snippets will lead to the default EntityGraph usage:

myRepository.findById(1L);
myRepository.findById(1L, EntityGraph.NOOP);
myRepository.findByName("bar");

The following snippets will ignore the default EntityGraph and instead use the EntityGraph passed as argument:

myRepository.findById(1L, NamedEntityGraph.loading("alice"));
myRepository.findByName("bar", NamedEntityGraph.loading("barry"));

Chaining EntityGraph definition with query execution

If you prefer fluent apis, you can use any instance of EntityGraph like this:

List<Product> products = ProductEntityGraph
                          .____()
                          .brand()
                          .____
                          .maker()
                          .address()
                          .____
                          .____()
                          .execute(entityGraph -> myRepository.findByLabel("foo", entityGraph));

EntityGraph Semantics

JPA 2.1 defines 2 semantics:

Spring Data JPA EntityGraph uses Load Graph Semantics as the default semantic. This means if you don't define a semantic, EntityGraph implementations will be built using Load Graph Semantics.

Each provided EntityGraph implementation provides an easy way to select the Graph Semantics.

Demo

You can play with https://github.com/Cosium/spring-data-jpa-entity-graph-sample to see the extension in action in a simple Spring Application.

Compatibility matrix

Spring Data JPA version Spring Data JPA EntityGraph version
3.2.1+ Maven Central 3.2.2+
3.2.0 Maven Central 3.2.1
3.1.x Maven Central 3.1.x
3.0.x Maven Central 3.0.x
2.7.x Maven Central 2.7.x
2.6.x Maven Central 2.6.x
2.5.x Maven Central 2.5.x
2.4.x Maven Central 2.4.x
2.3.x Maven Central 2.3.x
2.2.x Maven Central 2.2.x
2.1.x Maven Central 2.1.x
2.0.x Maven Central 2.0.x
1.11.x Maven Central 1.11.x
1.10.x Maven Central 1.10.x

For example, if you were using spring-data-jpa 2.2.x in your project, you would need to select any spring-data-jpa-entity-graph 2.2.x. Thus spring-data-jpa-entity-graph 2.2.8 would be eligible.

"Making JPA Great Again" talk

This talk was given at Paris JUG in January 2019.

The slides are in english.
The video is in French:
Alt text

Genesis

This project was created following spring-projects/spring-data-jpa#1120 discussion.

spring-data-jpa-entity-graph's People

Contributors

cedricboisselrichard avatar czp3009 avatar dependabot[bot] avatar devnied avatar heniu20 avatar hugothomas avatar huijiewei avatar leassis avatar reda-alaoui avatar thyming avatar wojciechkedziora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-data-jpa-entity-graph's Issues

Feat. Customizing EntityGraphQuerydslRepository (making delegate protected)

Would you consider making the QueryDsl Delegate protected (or a getter to it) in EntityGraphQuerydslRepository so it would be possible to make use of your great EntityGraph handling and still allowing further customization?

My UseCase would be to customize Spring Data QueryDsl to use Spring Data Projection, see
https://stackoverflow.com/questions/18300465/spring-data-jpa-and-querydsl-to-fetch-subset-of-columns-using-bean-constructor-p/35087403#35087403 .

Alternatively you could take the whole Projection Extension in either EntityGraphQuerydslRepository or in a new EntityGraphProjectionQuerydslRepository to make it part of your Cosium Package.

If you want to further discuss it with me, I'd gladly brainstorm with you. Thanks.

Does not work with @Query since Spring Data JPA 2.3.0

I have the following generic repo in my application.

@NoRepositoryBean
public interface BaseDeploymentRepo<T extends Deployment> extends EntityGraphJpaRepository<T, Long> {
    @Query(value="SELECT D"
           + "    FROM #{#entityName} D"
           + "    WHERE D.workspaceCode = :workspaceCode"
           + "    AND D.startDate <= :rangeEndDate"
           + "    AND D.endDate >= :rangeStartDate")
    // The [rangeStartDate, rangeEndDate] must have an overlap with [startDate, endDate] => startDate <= rangeEndDate && endDate >= rangeStartDate
    List<T> findAllDeploymentsWithinRange(String workspaceCode, LocalDate rangeStartDate, LocalDate rangeEndDate, EntityGraph entityGraph);
}

When I start the application after upgrading to 2.3.0, I'm seeing the following error in log.

Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract java.util.List com.ft.common.db.customer.repo.BaseDeploymentRepo.findAllDeploymentsWithinRange(java.lang.String,java.time.LocalDate,java.time.LocalDate,com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph) but parameter 'Optional[entityGraph]' not found in annotated query 'SELECT D    FROM #{#entityName} D    WHERE D.workspaceCode = :workspaceCode    AND D.startDate <= :rangeEndDate    AND D.endDate >= :rangeStartDate'!
	at org.springframework.data.jpa.repository.query.JpaQueryMethod.assertParameterNamesInAnnotatedQuery(JpaQueryMethod.java:157)
	at org.springframework.data.jpa.repository.query.JpaQueryMethod.<init>(JpaQueryMethod.java:136)
	at com.cosium.spring.data.jpa.entity.graph.repository.query.EntityGraphAwareJpaQueryMethod.<init>(EntityGraphAwareJpaQueryMethod.java:18)
	at com.cosium.spring.data.jpa.entity.graph.repository.query.EntityGraphAwareJpaQueryMethodFactory.build(EntityGraphAwareJpaQueryMethodFactory.java:22)
	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:81)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:99)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(QueryExecutorMethodInterceptor.java:92)

This didn't happen when I was on Spring Boot 2.2.7 and library 2.2.8.

Do not ignore empty entitygraph

Since https://hibernate.atlassian.net/browse/HHH-8776 and following #35 , Hibernate makes a difference between LOAD and FETCH graph. Thanks to that, an empty FETCH graph can be used to mark all entity attributes as LAZY, including those annotated with EAGER.

Currently this extension consider this kind of entity graphs as ignorable. They are not passed to the ORM and trigger fallback to an eventual default entitygraph.

Support annotationProcessorPaths for the Graph Generator

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. Add spring-data-jpa-entity-graph dependency
  2. Add spring-data-jpa-entity-graph-generator in annotationProcessorPaths
  3. mvn compile

Example maven-complier-plugin configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <annotationProcessorPaths>
            <path>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-configuration-processor</artifactId>
                <version>${spring-boot.version}</version>
            </path>
            <path>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>${hibernate.version}</version>
            </path>
            <path>
                <groupId>com.cosium.spring.data</groupId>
                <artifactId>spring-data-jpa-entity-graph-generator</artifactId>
                <version>2.4.1</version>
            </path>
        </annotationProcessorPaths>
        <compilerArgs>
            <compilerArg>-Amapstruct.suppressGeneratorTimestamp=true</compilerArg>
            <compilerArg>-Amapstruct.suppressGeneratorVersionInfoComment=true</compilerArg>
        </compilerArgs>
    </configuration>
</plugin>

What is the expected output?
Build success

What happens instead?
Build fails with: java.lang.NoClassDefFoundError: javax/persistence/metamodel/StaticMetamodel: javax.persistence.metamodel.StaticMetamodel

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.4.2
  • ORM with version: 5.4.25.Final
  • spring-data-jpa-entity-graph version: 2.4.1

Additional context
To fix the issue I tested removing <scope>provided</scope> from generator/pom.xml.
Afterward, the build partially succeeded, but this failure is due to a different problem that shouldn't be directly related to this issue.

NoClassDefFoundError: com/mysema/commons/lang/Assert

It looks like spring-data-jpa-entity-graph depends on the class com.mysema.commons.lang.Assert, but the mysema-commons-lang library isn't declared as transitive dependency.

My setup is as follows:

  • I'm using Spring Boot with Gradle as build system and the spring-boot Gradle plugin
  • I added a dependency to Spring Data JPA as described in the documentation
  • I added a dependency to the spring-data-jpa-entity-graph library as described in the documentation

Here's my build.gradle:

plugins {
    id 'org.springframework.boot' version '1.5.1.RELEASE'
}

apply plugin: 'java'
apply plugin: 'eclipse'

repositories {
    mavenCentral()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("com.cosium.spring.data:spring-data-jpa-entity-graph:1.11.01")
    [...]
}

Spring Data JPA resolves the following dependencies:

 org.springframework.boot:spring-boot-starter-data-jpa: -> 1.5.1.RELEASE
    +--- org.springframework.boot:spring-boot-starter:1.5.1.RELEASE (*)
    +--- org.springframework.boot:spring-boot-starter-aop:1.5.1.RELEASE
    |    +--- org.springframework.boot:spring-boot-starter:1.5.1.RELEASE (*)
    |    +--- org.springframework:spring-aop:4.3.6.RELEASE (*)
    |    \--- org.aspectj:aspectjweaver:1.8.9
    +--- org.springframework.boot:spring-boot-starter-jdbc:1.5.1.RELEASE
    |    +--- org.springframework.boot:spring-boot-starter:1.5.1.RELEASE (*)
    |    +--- org.apache.tomcat:tomcat-jdbc:8.5.11
    |    |    \--- org.apache.tomcat:tomcat-juli:8.5.11
    |    \--- org.springframework:spring-jdbc:4.3.6.RELEASE
    |         +--- org.springframework:spring-beans:4.3.6.RELEASE (*)
    |         +--- org.springframework:spring-core:4.3.6.RELEASE
    |         \--- org.springframework:spring-tx:4.3.6.RELEASE
    |              +--- org.springframework:spring-beans:4.3.6.RELEASE (*)
    |              \--- org.springframework:spring-core:4.3.6.RELEASE
    +--- org.hibernate:hibernate-core:5.0.11.Final -> 5.2.3.Final
    |    +--- org.jboss.logging:jboss-logging:3.3.0.Final
    |    +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
    |    +--- org.javassist:javassist:3.20.0-GA -> 3.21.0-GA
    |    +--- antlr:antlr:2.7.7
    |    +--- org.jboss:jandex:2.0.0.Final
    |    +--- com.fasterxml:classmate:1.3.0 -> 1.3.3
    |    +--- dom4j:dom4j:1.6.1
    |    \--- org.hibernate.common:hibernate-commons-annotations:5.0.1.Final
    |         \--- org.jboss.logging:jboss-logging:3.3.0.Final
    +--- org.hibernate:hibernate-entitymanager:5.0.11.Final -> 5.2.3.Final
    |    +--- org.jboss.logging:jboss-logging:3.3.0.Final
    |    +--- org.hibernate:hibernate-core:5.2.3.Final (*)
    |    +--- dom4j:dom4j:1.6.1
    |    +--- org.hibernate.common:hibernate-commons-annotations:5.0.1.Final (*)
    |    +--- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
    |    \--- org.javassist:javassist:3.20.0-GA -> 3.21.0-GA
    +--- javax.transaction:javax.transaction-api:1.2
    +--- org.springframework.data:spring-data-jpa:1.11.0.RELEASE
    |    +--- org.springframework.data:spring-data-commons:1.13.0.RELEASE
    |    |    +--- org.springframework:spring-core:4.3.6.RELEASE
    |    |    +--- org.springframework:spring-beans:4.3.6.RELEASE (*)
    |    |    +--- org.slf4j:slf4j-api:1.7.22
    |    |    \--- org.slf4j:jcl-over-slf4j:1.7.22 (*)
    |    +--- org.springframework:spring-orm:4.3.6.RELEASE
    |    |    +--- org.springframework:spring-beans:4.3.6.RELEASE (*)
    |    |    +--- org.springframework:spring-core:4.3.6.RELEASE
    |    |    +--- org.springframework:spring-jdbc:4.3.6.RELEASE (*)
    |    |    \--- org.springframework:spring-tx:4.3.6.RELEASE (*)
    |    +--- org.springframework:spring-context:4.3.6.RELEASE (*)
    |    +--- org.springframework:spring-aop:4.3.6.RELEASE (*)
    |    +--- org.springframework:spring-tx:4.3.6.RELEASE (*)
    |    +--- org.springframework:spring-beans:4.3.6.RELEASE (*)
    |    +--- org.springframework:spring-core:4.3.6.RELEASE
    |    +--- org.slf4j:slf4j-api:1.7.22
    |    \--- org.slf4j:jcl-over-slf4j:1.7.22 (*)
    \--- org.springframework:spring-aspects:4.3.6.RELEASE
         \--- org.aspectj:aspectjweaver:1.8.9

... and spring-data-jpa-entity-graph doesn't resolve any transitive dependencies.


And here's the error:

Caused by: java.lang.NoClassDefFoundError: com/mysema/commons/lang/Assert
        at com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils.fromAttributePaths(EntityGraphUtils.java:49) ~[spring-data-jpa-entity-graph-1.11.01.jar:na]

It would probably be desirable to avoid the dependency on mysema-commons-lang to reduce spring-data-jpa-entity-graph's dependency footprint.

Spring Data 2.0 uses Optional<T> findOne

The EntityGraphQuerydslPredicateExecutor currently uses the following signature:

T findOne(Predicate predicate, EntityGraph entityGraph);

In Spring Data 2.0 the {{QuerydslPredicateExecutor}} is changed to:

Optional<T> findOne(Predicate var1);

I think this library should upgrade to the Optional<T> as well for findOne.

Spring Data Commons 2.0.0 is not compatible

In Spring Data Commons 2.0.0 (currently only milestones being released) QueryDslPredicateExecutor seems to be renamed to QuerydslPredicateExecutor.

Spring Boot 2.0 uses Spring Data 2.0 so currently there is no way to upgrade from Spring Boot 1.5.x to 2.0.

I don't know why they renamed it but it causes some incompatibilities unfortunately.

EntityGraph applied on QueryDsl Pagination count query

First of all, many thanks for your extension, idea is just great.
However, I have issue with Pageable JPA repository.

In short, you can read that topic that describes same things that I found during my investigation.

In 2 words: Pageable JpaRepository takes original query and turns it into select count(main_entity.id) ... just by replacing original select field1, field2, ..., fieldN part. As result, final statement looks like:
select count(c.id) from Company c INNER JOIN FETCH c.employees WHERE c.id = :companyId"
But Hibernate doesn't like "useless joins", i.e. when fields from c.employees is not part of select.

It leads to Hibernate Exception
org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list.

Just wondering if you have any workaround for that case or probably I'm missing something...

Equals and hashCode on AbstractEntityGraph?

This is maybe a question and maybe and issue - I ran into a problem where I had introduced this project as a dependency (thanks!) but mock calls were failing to match because I (incorrectly) assumed that EntityGraphs.named("x").equals(EntityGraphs.named("x")) is true. Is there a reason that equals and hashCode are not implemented? Would you accept a PR adding this to AbstractEntityGraph?

Hibernate executes extra SELECT query for to-one relationships

When I use this library for to-many relationships, everything is working fine. However, I notice a strange behaviour when it comes to to-one relationships with Hibernate Bytecode Enhancer.

In my application, I have the following entities

@Entity(name="DemoAccount")
@Table(name="staff")
@Getter @Setter @FieldNameConstants
@NoArgsConstructor
public class Account {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    protected Long id;
    @Column(name="username", nullable=false)
    private String userId;
    private String name;

    @ManyToOne(fetch=FetchType.LAZY)
    @LazyToOne(LazyToOneOption.NO_PROXY)
    @LazyGroup("nationality")
    @JoinColumn(name="nationality", referencedColumnName="code")
    private Nationality nationality;
}

@Entity(name="DemoNationality ")
@Table(name="nationality ")
@Getter @Setter @FieldNameConstants
@NoArgsConstructor
public class Nationality {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    protected Long id;
    @Column(name="code", nullable=false)
    private String code;
    private String name;
}

I'm using the following @Repository to look for Account.

@Repository
public interface AccountRepo extends EntityGraphJpaRepository<Account, Long> {
    Optional<Account> findByUserId(String userId, EntityGraph entityGraph);
}

My test endpoint contains a simple method.

@CustomerTransactional
@GetMapping("/profile")
public void testProfile(@RequestParam String userId) {
    Optional<Account> account = accountRepo.findByUserId(userId, EntityGraphs.create(Account.Fields.nationality));
    if (account.isPresent()) {
        System.out.println(account.get().getName());
        System.out.println(account.get().getNationality().getName());
    }
}

When I execute this endpoint, this is what I'm seeing in the log.

2020-05-24 16:18:26,492 DEBUG [http-nio-9000-exec-1] org.hibernate.SQL   : 
    /* select
        generatedAlias0 
    from
        DemoAccount as generatedAlias0 
    where
        generatedAlias0.userId=:param0 */ select
            account0_.id as id1_61_0_,
            nationalit1_.id as id1_35_1_,
            account0_.name as name4_61_0_,
            account0_.username as username6_61_0_,
            nationalit1_.code as code2_35_1_,
            nationalit1_.name as name4_35_1_
        from
            staff account0_ 
        left outer join
            nationality nationalit1_ 
                on account0_.nationality=nationalit1_.code 
        where
            account0_.username=?
2020-05-24 16:18:26,492 TRACE [http-nio-9000-exec-1] org.hibernate.type.descriptor.sql.BasicBinder   : binding parameter [1] as [VARCHAR] - [90000010]
Edgar Rey Tann
2020-05-24 16:18:26,506 DEBUG [http-nio-9000-exec-1] org.hibernate.SQL   : 
    /* sequential select
        com.ft.demo.db.customer.domain.Account */ select
            account_.nationality as nationa22_61_ 
        from
            staff account_ 
        where
            account_.id=?
2020-05-24 16:18:26,507 TRACE [http-nio-9000-exec-1] org.hibernate.type.descriptor.sql.BasicBinder   : binding parameter [1] as [BIGINT] - [660]
Indonesian

As you can see, in the middle of the account name and the nationality name, there's an extra query just to select the nationality field. It means if I have 50 records, 50 additional queries got executed. Is this an expected behaviour for your library?

Version:
Spring Boot 2.2.7
spring-data-jpa-entity-graph 2.2.8

Below is what I used in pom.xml to activate Hibernate Bytecode Enhancer

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.hibernate.orm.tooling</groupId>
        <artifactId>hibernate-enhance-maven-plugin</artifactId>
        <version>${hibernate.version}</version>
        <executions>
          <execution>
            <configuration>
              <failOnError>true</failOnError>
              <enableLazyInitialization>true</enableLazyInitialization>
            </configuration>
            <goals>
              <goal>enhance</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Original findById not using graph

Hello, I have just tried creating a project very similar to your example: https://github.com/Cosium/spring-data-jpa-entity-graph/blob/master/doc/MAIN.md and I found that when I try to use the original findById method from the EntityGraphCrudRepository, it would not use the default graph. It would also not work if I dynamically call my default graph like so: findById(1L, EntityGraphs.named("Product.default"));

Other custom methods like findByNameAndLastName will use the default like expected.

This behavior seems like it has something to do with updating an entity, or rather, calling save into an entity that already has an id.

When I save my entity for the first time, like product = prodRepo.save(prod), the default graph is used correctly. If I then immediately change something in that entity and save it again, I see the graph not being used.

            Product prod = new Product();
            prod.setName("Test");
            prod= prodRepository.save(prod); //Default graph used
            prod= prodRepository.findById(prod.getId()).get();  //Default graph used

            prod.setName("Test2");
            prod= prodRepository.save(prod);  //Default graph NOT used
            prod= prodRepository.findById(prod.getId()).get();  //Default graph NOT used
            prod= prodRepository.findById(prod.getId(), EntityGraphs.named("Product.default")).get();  //Default graph NOT used

Thank you very much for your help.

QueryException on pagination query with default entity graph

Hello,

I'm using spring-data-jpa-entity-graph 2.0.5 and i'm facing an issue with default entity graph in pagination queries. Here is my entity (relevant parts only) :

@Entity
@NamedEntityGraphs(
    value = {
        @NamedEntityGraph(
            name = "He.default",
            attributeNodes = {@NamedAttributeNode("practitioner")})
    })
public class He {
...

  @ManyToOne(fetch = FetchType.LAZY)
  private Customer customer;

  @ManyToOne(fetch = FetchType.LAZY)
  private User practitioner;

...

And here is the JPA repository :

interface HeRepository extends EntityGraphJpaRepository<He, Integer> {

Page<He> findByCustomer(Customer customer, Pageable pageable);

...

When I call findByCustomer and the results are >= of the page size : hibernate make a count query and throw the following exception :

org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias0,role=com.example.He.practitioner,tableName=utilisateurs,tableAlias=user1_,origin=He he0_,columns={he0_.practitioner_id ,className=com.example.User}}] [select count(generatedAlias0) from com.example.He as generatedAlias0 where generatedAlias0.customer=:param0]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=generatedAlias0,role=com.example.He.practitioner,tableName=utilisateurs,tableAlias=user1_,origin=He he0_,columns={he0_.practitioner_id ,className=com.example.User}}] [select count(generatedAlias0) from com.example.He as generatedAlias0 where generatedAlias0.customer=:param0]

	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:373)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:159)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:103)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:135)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.example.$Proxy181.findByCustomer(Unknown Source)

Thank you (and great job by the way !)

Cannot Bind EntityGraphRepositry

Hi,

Idea of the library is awesome, but i can't make it to work.
I am building SpringBoot Application and I have followed steps for integration from 2.0.0 documentation
page.
Spring throws errors on initialization. Repository bean is not defined.

Code

@Configuration @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class) public class DataRepositoryConfiguration { }

@Repository public interface PurchaseOrderRepository extends EntityGraphJpaRepository<PurchaseOrderEntity, Long> { PurchaseOrderEntity findFirstByOrderByCreatedAtDesc(); PurchaseOrderEntity findFirstByOrderByCreatedAtAsc(); }

@Autowired public PurchaseOrderService(PurchaseOrderRepository purchaseOrderRepository, UserOrderAssignmentRepository userOrderAssignmentRepository, PurchaseOrderMapper purchaseOrderMapper) { this.userOrderAssignmentRepository = userOrderAssignmentRepository; this.purchaseOrderMapper = purchaseOrderMapper; this.purchaseOrderRepository = purchaseOrderRepository; }

Error

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-03-21 22:36:44.608 ERROR 18380 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Parameter 0 of constructor in api.service.PurchaseOrderService required a bean of type 'api.repo.PurchaseOrderRepository' that could not be found.

Action:

Consider defining a bean of type 'api.repo.PurchaseOrderRepository' in your configuration.

Process finished with exit code 0

MappedSuperclass annotation issue

Hi,
I am using 1.11.03 and I have the spring configuration in xml in this way:

	<jpa:repositories base-package="my.package.datamodel.repositories"
	                  factory-class="com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphJpaRepositoryFactoryBean"
	                  entity-manager-factory-ref="entityManagerFactory" />

I have some classes annotated with @MappedSuperclass and I have this issue:

java.lang.IllegalArgumentException: Not an entity: class com.liberologico.cloudesire.datamodel.entities.MetadataEntity
	at org.hibernate.metamodel.internal.MetamodelImpl.entity(MetamodelImpl.java:456)
	at org.hibernate.metamodel.internal.MetamodelImpl.findEntityGraphsByType(MetamodelImpl.java:687)
	at org.hibernate.internal.SessionFactoryImpl.findEntityGraphsByType(SessionFactoryImpl.java:545)
	at org.hibernate.internal.SessionImpl.getEntityGraphs(SessionImpl.java:3856)
	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347) [3 skipped]
	at com.sun.proxy.$Proxy166.getEntityGraphs(Unknown Source)
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298) [3 skipped]
	at com.sun.proxy.$Proxy166.getEntityGraphs(Unknown Source)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryEntityManagerEntityGraphInjector.invoke(RepositoryEntityManagerEntityGraphInjector.java:59) [6 skipped]
	at com.sun.proxy.$Proxy169.getEntityGraphs(Unknown Source) [2 skipped]
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.findDefaultEntityGraph(RepositoryMethodEntityGraphExtractor.java:88)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.<init>(RepositoryMethodEntityGraphExtractor.java:79)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor.postProcess(RepositoryMethodEntityGraphExtractor.java:46)

Generated query columns not effected by the entity graph

In a spring boot application with spring data jpa entity graph, I am extending the EntityGraphCrudRepository and also tried EntityGraphJpaRepository, the generated query columns is not effected by the passed entity graph object (all the columns still returned).

Kindly check the generated query in the comment block below in the sample application:

///////////////// Person class

@Data
@Entity
public class Person {
	@Id
	@GeneratedValue
	private Long id;
	private String name;
	private int age;
}


///////////////// PersonDAO interface

public interface PersonDAO extends EntityGraphJpaRepository<Person, Long>{
	public List<Person> findByNameLike(String name, EntityGraph eg);
}


///////////////// EntityGraphTestApplication  class

@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class)
public class EntityGraphTestApplication implements CommandLineRunner{


	@Autowired
	private PersonDAO dao;
	
	public static void main(String[] args) {
		SpringApplication.run(EntityGraphTestApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		Person p1 = new Person();
		p1.setAge(10); 
		p1.setName("person1");
		
		Person p2 = new Person();
		p2.setAge(10); 
		p2.setName("person2");
		
		Person p3 = new Person();
		p3.setAge(10); 
		p3.setName("person3");
		
		dao.save(p1);
		dao.save(p2);
		dao.save(p3);
		
		
		dao.findAll(EntityGraphUtils.fromAttributePaths("name", "age"));
		/*	-- Generated query below:
		 * 
		 * 
		    select
		        person0_.id as id1_0_,
		        person0_.age as age2_0_,
		        person0_.name as name3_0_ 
		    from
		        person person0_
		 * 
		 * 
		 * */
		
		
		dao.findByNameLike("person1", EntityGraphUtils.fromAttributePaths("name"));
		/*	-- Generated query below:
		 * 
		    select
		        person0_.id as id1_0_,
		        person0_.age as age2_0_,
		        person0_.name as name3_0_ 
		    from
		        person person0_ 
		    where
		        person0_.name like ?
		 * 
		 * 
		 * */			
	}
}

Dependencies:

	<!-- Spring data jpa entity graph-->
	<dependency>
		<groupId>com.cosium.spring.data</groupId>
		<artifactId>spring-data-jpa-entity-graph</artifactId>
		<version>2.0.7</version>
	</dependency>
	
	<!-- H2 database -->
	<dependency>
		<groupId>com.h2database</groupId>
		<artifactId>h2</artifactId>
		<scope>runtime</scope>
	</dependency>

application.yml:

spring:
  h2:
    console:
      enabled: true
    datasource: 
      url: jdbc:h2:mem:testdb
      username: sa
      password:
      driverClassName: org.h2.Driver
    
  jpa:
    generate-ddl: true
    hibernate:
      ddl-auto: create
    properties:
      hibernate:
        dialect: org.hibernate.dialect.H2Dialect
        format_sql: true
        
logging:
  level:
    root: warn
    org:
      hibernate:
        SQL: debug
        type: trace
      springframework:
        web: debug

Repository bean not found

Hi,

I am using spring jpa 2.2.6.RELEASE and spring-data-jpa-entity-graph 2.2.8.
I have added @EnableJpaRepositories(repositoryFactoryBeanClass =
EntityGraphJpaRepositoryFactoryBean.class) to config class.

Repository bean is Extending EntityGraphJpaRepository<T, Integer>,EntityGraphQuerydslPredicateExecutor.

I have followed all steps as mentiioned in the docs.

JPA Config.
`
@configuration
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
@EnableJpaRepositories(repositoryFactoryBeanClass =
EntityGraphJpaRepositoryFactoryBean.class)
//@EnableJpaRepositories
public class JpaConfig {

        @Bean
        public AuditorAware<String> auditorAware() {
            return new AuditorImpl();
        }
        
        @Bean
        public JPAQueryFactory jpaQueryFactory(EntityManager entityManager)
        {
            return new JPAQueryFactory(entityManager);
        }
        } `

Repository:.

        `
        public interface GeneralRepository<T> extends EntityGraphJpaRepository<T, Integer>,EntityGraphQuerydslPredicateExecutor<T> {

        }
        `

Using spring-data-jpa-entity-graph with Hibernate enhanced bytecode

We have this kind of entity:

@Entity
public class Stuff {

 @Id
  private Integer id;

  @Lob
  @Basic(fetch = FetchType.LAZY)
  private byte[] data;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "other_id", referencedColumnName = "id", nullable = false)
  private OtherClass other;
}

To be able to lazily fetch the data column, we have to use the hibernate-enhance-maven-plugin with hibernate.enhancer.enableLazyInitialization=true

But, it looks like the entity graph magic stuff doesn't play well with it.

When we try to fetch all Stuff from database, we proceed like this:

Iterable<Stuff> stuffes =  repository.findAll(EntityGraphUtils.fromAttributePaths("other"));

In the hibernate log, we can see that the data field is not fetched as intended, but we see a SELECT request for each OtherClass, which is precisely what we tries to avoid by using the entity graph.

When we remove the hibernate-enhance-maven-plugin from the pom.xml, the entity graph works just fine, but the data column is always eagerly fetched.

We are not really sure if the issue comes from spring-data-jpa-entity-graph or from elsewhere, but maybe you have an idea of the source of the problem?

Support MongoDB so applications can use either Spring Data JPA and Spring Data Mongo

I know the concept of EntityGraphs do not map to MongoDB databases but would like to see an addition to this library so it could be used in applications that want to support running with either a JPA or Mongo Database.

Something like com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphMongoDBRepositoryFactoryBean which will just create repositories that will ignore the Named Entity parameter on invocations.

Possibly include this library in a separate module so it does not force people to include Spring Data Mongo dependencies.

EntityGraphJpaRepositoryFactoryBean and @DataJpaTest

I try to test my service with repository that use EntityGraphJpaRepository and always get
Failed to create query for method public abstract java.util.List xxx.findByProjectPublicId(java.lang.String,com.cosium.spring.data.jpa.entity.graph.domain.EntityGraph)! At least 2 parameter(s) provided but only 1 parameter(s) present in query.
at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.(PartTreeJpaQuery.java:82)

Ad-hoc attribute paths

Hey Guys and Gals!

So i've ran into the same problem as you did with Spring Data JPA as you did, i'm super happy that you made this plugin to solve it, huge-huge kudos, it already made my life easier!

I was thinking, Spring has ad-hoc entity graphs (see example 60th):

@Repository
public interface GroupRepository extends CrudRepository<GroupInfo, String> {

  @EntityGraph(attributePaths = { "members" })
  GroupInfo getByGroupName(String name);

}

Would it be convenient to do this:

final ProductRepository repo;
repo.findAll(EntityGraphUtils.fromAttributePaths("brand", "maker"));

?

I would be happy to research and make a pr about this if you think it would be helpful as well, let me know what do you think. :)

Have a pancake flavoured day,
-Dan

Cannot find @NamedSubgraph Capability

There is Department entity that has field LocationEntity as @manytoone. LocationEntity entity has several fields streetAddress, postalCode, city etc... If I specify EntityGraphUtils.fromAttributePaths(new String[] {"department.location", "department.location.streetAddress"}) I can see that Hibernate fetches all fields from location table even though I specified only streetAddress field. I've been wondering if there is any capability such as @NamedSubgraph to able to specify only the needed fields to be fetched from child entity?

Entitygraph does not work for Microsoft SQL

i am using your repository

<dependency>
    <groupId>com.cosium.spring.data</groupId>
    <artifactId>spring-data-jpa-entity-graph</artifactId>
    <version>2.4.2</version>
    <!--<version>${springframework.boot.version}</version>-->
</dependency>

With spring-boot
<springframework.boot.version>2.4.5</springframework.boot.version>

The subgraph works really fine, if I have a mysql database.

Now I changed my db from mysql to Microsoft sql Server and I return the following error:
There was an exception while trying to navigate to 'booking' with the exception message 'failed to lazily initialize a collection of role: sit.app.container.backend.data.entity.LoosePlanningForDay.regularSlots, could not initialize proxy - no Session'

For the msyql-variant with subgraph everything works.

Do you have some hint for me how to fix this issue?

My properties are:

datasource:  
  driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.SQLServerDialect

spring-data-jpa-entity-graph-generator with gradle throws ClassCastException

I get the following error while building with gradle:

class com.sun.tools.javac.code.Type$ArrayType cannot be cast to class javax.lang.model.type.DeclaredType (com.sun.tools.javac.code.Type$ArrayType is in module jdk.compiler of loader 'app'; javax.lang.model.type.DeclaredType is in module java.compiler of loader 'platform')

An extract from build.gradle with lombok and querydsl:

implementation 'org.hibernate:hibernate-java8:5.6.1.Final'
annotationProcessor 'org.hibernate:hibernate-jpamodelgen:5.4.0.Final'
implementation 'com.cosium.spring.data:spring-data-jpa-entity-graph:2.5.0'
annotationProcessor 'com.cosium.spring.data:spring-data-jpa-entity-graph-generator:2.5.0'

Entity_ files are generated, if annotationProcessor 'com.cosium.spring.data:spring-data-jpa-entity-graph-generator:2.5.0' is removed from the build.

Hibernate reports WARNING: HHH000104 when using findAll(spec, pageable, entitygraph) when join fetch a collection

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. Create two entities with a Many-To-Many relationship
  2. Call findAll(spec, pageable, entitygraph) to retrieve paginated results with the collection loaded
  3. Hibernate reports WARNING: o.h.h.internal.ast.QueryTranslatorImpl : HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!

What is the expected output?
No warning. No retrieve all data in memory

What happens instead?
all data loaded into memory for pagination

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.2.1.RELEASE
  • ORM with version: Hibernate 5.4.8
  • spring-data-jpa-entity-graph version: 2.2.8

Link to an automated test demonstrating the problem:
The absence of such automated test will probably delay the issue resolution.
To create such a test, fork https://github.com/Cosium/spring-data-jpa-entity-graph then add a test in core/src/test/java directory.

Additional context
Add any other context about the problem here.

Bean repository could not be found

With spring-boot-starter-parent= 2.5.4 , java version 11 and spring-data-jpa-entity-graph.version 2.5.0 (or <) a Bean Repository could not be found on application start.


APPLICATION FAILED TO START


Description:

Field userRepository in com.ead.authuser.service.impl.UserServiceImpl required a bean of type 'com.ead.authuser.repository.UserRepository' that could not be found.


@Configuration @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class) public class JpaRepositoryConfig { }

`@Repository
public interface UserRepository extends GenericRepository<User, UUID> {

boolean existsByLoginOrEmail(String login, String email);
User getByLoginOrEmail(String login, String email);

}`

public interface GenericRepository<MODEL extends AbstractEntity, MODEL_ID extends Serializable> extends //JpaRepository<MODEL, MODEL_ID>, JpaSpecificationExecutor<MODEL> EntityGraphJpaRepository<MODEL, MODEL_ID>, EntityGraphJpaSpecificationExecutor<MODEL> { }

Note that when I use "extends JpaRepository<MODEL, MODEL_ID>, JpaSpecificationExecutor" the application works fine.

Problems with queries from parallel thread. (DeferredResult)

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. Write a Controller where a deferred value is returned.
  2. Create a query to the repository insite the parallel thread.
  3. Make a REST request to the Controller while running it in Intellij. (It will work)
  4. Deploy your project into Docker and run the Container. The Rest request will fail with a InvalidDataAccessApiUsageException.

What is the expected output?
It should be possible to execute a query from a parallel thread without an exception.

What happens instead?
An exception is thrown.

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.5.9
  • ORM with version: 5.4.33
  • spring-data-jpa-entity-graph version: 2.5.0

Link to an automated test demonstrating the problem:
Should be easy to run a Controller with a deferred result.

Additional context
Here is may Stacktrace:

org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader; nested exception is java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader; nested exception is java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
    at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:374)
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:158)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:102)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
    at com.sun.proxy.$Proxy123.findAll(Unknown Source)
    at de.gvl.kmw.mwm.participationadviceservice.domain.ParticipationAdviceRepository.getParticipationAdvicesForUser(ParticipationAdviceRepository.java:17)
    at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:86)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:158)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:102)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
    at com.sun.proxy.$Proxy123.getParticipationAdvicesForUser(Unknown Source)
    at de.gvl.kmw.mwm.participationadviceservice.ui.rest.ParticipationAdvicesApiDelegateImpl.lambda$getParticipationAdvicesForUser$0(ParticipationAdvicesApiDelegateImpl.java:48)
    at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Proxy.java:858)
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:681)
    at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:627)
    at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:426)
    at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
    at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
    at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:424)
    at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:126)
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:118)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:97)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryQueryEntityGraphInjector.proxy(RepositoryQueryEntityGraphInjector.java:46)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryEntityManagerEntityGraphInjector.invoke(RepositoryEntityManagerEntityGraphInjector.java:72)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
    at com.sun.proxy.$Proxy121.createQuery(Unknown Source)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:757)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:708)
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:484)
    at com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphSimpleJpaRepository.findAll(EntityGraphSimpleJpaRepository.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289)
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
    at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:529)
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:599)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:163)
    at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
    ... 36 common frames omitted
I will attach the classes you might be interested in.

Thank you in advance.

src.zip

Java 12 Support

Hi there,

I just tried to use spring-data-jpa-entity-graph 2.1.0 with openjdk-12.0.1 and it throws a NoSuchFieldException:

Caused by: java.lang.NoSuchFieldException: modifiers at java.base/java.lang.Class.getDeclaredField(Class.java:2417) at com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphJpaRepositoryFactory.addEntityGraphToSpecialTypes(EntityGraphJpaRepositoryFactory.java:58) ... 52 common frames omitted

Thanks in advance for looking into this.

Stop using illegal reflective access

Hi All

We're on gradle 5.1 and are seeing this message during builds using spring-data-jpa-entity-graph v2.07.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphJpaRepositoryFactory (file:[TRUNCATED]/caches/modules-2/files-2.1/com.cosium.spring.data/spring-data-jpa-entity-graph/2.0.7/397ec4ad1ccef66f9ac5aab08034d837dd3b1067/spring-data-jpa-entity-graph-2.0.7.jar) to field java.lang.reflect.Field.modifiers
WARNING: Please consider reporting this to the maintainers of com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphJpaRepositoryFactory
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Just wanted to report it in case it's useful.

I get the following exception: org.springframework.dao.InvalidDataAccessApiUsageException

Hi!

Thank you for your powerful library.
Everything worked very well in my IDE (Intellij) until I deployed my project to docker.
When executing a query then the following exception occurs:

org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader; nested exception is java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader; nested exception is java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:374)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:158)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:102)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy123.findAll(Unknown Source)
	at de.gvl.kmw.mwm.participationadviceservice.domain.ParticipationAdviceRepository.getParticipationAdvicesForUser(ParticipationAdviceRepository.java:17)
	at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:710)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:86)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:158)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:102)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy123.getParticipationAdvicesForUser(Unknown Source)
	at de.gvl.kmw.mwm.participationadviceservice.ui.rest.ParticipationAdvicesApiDelegateImpl.lambda$getParticipationAdvicesForUser$0(ParticipationAdvicesApiDelegateImpl.java:48)
	at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.IllegalArgumentException: org.hibernate.query.spi.QueryImplementor referenced from a method is not visible from class loader
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.ensureVisible(Proxy.java:858)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.validateProxyInterfaces(Proxy.java:681)
	at java.base/java.lang.reflect.Proxy$ProxyBuilder.<init>(Proxy.java:627)
	at java.base/java.lang.reflect.Proxy.lambda$getProxyConstructor$1(Proxy.java:426)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue$Memoizer.get(AbstractClassLoaderValue.java:329)
	at java.base/jdk.internal.loader.AbstractClassLoaderValue.computeIfAbsent(AbstractClassLoaderValue.java:205)
	at java.base/java.lang.reflect.Proxy.getProxyConstructor(Proxy.java:424)
	at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1006)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:126)
	at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:118)
	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:97)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryQueryEntityGraphInjector.proxy(RepositoryQueryEntityGraphInjector.java:46)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryEntityManagerEntityGraphInjector.invoke(RepositoryEntityManagerEntityGraphInjector.java:72)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy121.createQuery(Unknown Source)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:757)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:708)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:484)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphSimpleJpaRepository.findAll(EntityGraphSimpleJpaRepository.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
	at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:529)
	at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:599)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:163)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	... 36 common frames omitted

Something seems to be missing in the deployed artifact.
Do you have an idea what?

Thanks in advance!
Thorsten

PS: I will attach the most important files.
src.zip

"No property [repositoryMethod] found for type [entity]!"

I'm trying to integrate your extension into my project but I'm having some trouble: whenever I add a method with a signature containing EntityGraph to my repository, I'm getting the error mentioned in the title.

For example, I have an interface CrudRepository I created. It is similar to Spring Data JPA's CrudRepository with the exception that it returns Optional<T> for single element find methods. I added the following declaration:

Optional<T> findOne(ID id, EntityGraph graph);

And I'm getting the following error at application startup (MyEntityRepository interface extends CrudRepository):

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myEntityRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findOne found for type MyEntity!
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        ... 37 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findOne found for type MyEntity!
        at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:247) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:398) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:378) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:86) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:64) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:103) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:214) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:436) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:221) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:277) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.13.0.RELEASE.jar:na]
        at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:101) ~[spring-data-jpa-1.11.0.RELEASE.jar:na]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
        ... 47 common frames omitted

Your extension just has to be on the classpath for it to work, right? What could I be doing wrong?

Allow usage of smallest repository interfaces

Spring Data JPA 1.11.x includes a QueryByExampleExecutor (part of Spring Data Commons >=1.12).

It would be nice to have a JpaEntityGraphQueryByExampleExecutor to support providing the entity graph.

Circular dependencies when using @EntityListeners

What steps will reproduce the problem?
Steps to reproduce the behavior:
I have an Entity with a Listener:

@Entity
@EntityListeners(MyEntityUpdateListener.class)
public class MyEntity {
...

and the Listener needs to modify the database, so it needs a Repository or the entityManager:

public class MyEntityUpdateListener {
    private final EntityManager entityManager;

    public MyEntityUpdateListener(EntityManager _em) {
...

When starting this, I get

***************************
APPLICATION FAILED TO START
***************************

Description:

The dependencies of some of the beans in the application context form a cycle:

...
      ↓
   myRepository defined in ....MyRepository defined in @EnableJpaRepositories declared on MyApplication
      ↓
   (inner bean)#55e91e61
β”Œβ”€β”€β”€β”€β”€β”
|  entityManagerFactory defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]
↑     ↓
|  ....MyEntityUpdateListener
↑     ↓
|  org.springframework.orm.jpa.SharedEntityManagerCreator#0
β””β”€β”€β”€β”€β”€β”˜

What is the expected output?

This works fine with standard Spring Boot.

What happens instead?

Should also work with spring-data-jpa-entity-graph

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.3.4.RELEASE
  • ORM with version: 5.4.21.Final
  • spring-data-jpa-entity-graph version: 2.3.1, 2.4.2, 2.5.0

Things I have tried (none have worked):

  • change from constructor injection to @Autowired - variable will be null
  • change from EntityManager to requiring a Repository - no change
  • use @PostUpdate annotation in the Entity class - same error

Error creating bean

Hi, I'm trying to set up for the first time but am getting the following error:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.cesicorp.magrathea.repository.UserRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1506) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ... 36 common frames omitted

Using spring-data-jpa version 2.0.9.RELEASE as seen here:
[INFO] +- org.springframework.boot:spring-boot-loader-tools:jar:2.0.4.RELEASE:compile [INFO] | \- org.apache.commons:commons-compress:jar:1.14:compile [INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.0.4.RELEASE:compile [INFO] | \- io.micrometer:micrometer-core:jar:1.0.6:compile [INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.10:compile [INFO] | \- org.latencyutils:LatencyUtils:jar:2.0.3:compile [INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.0.4.RELEASE:compile [INFO] | \- org.aspectj:aspectjweaver:jar:1.8.13:compile [INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.0.4.RELEASE:compile [INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.4.RELEASE:compile [INFO] | | \- org.springframework:spring-jdbc:jar:5.0.8.RELEASE:compile [INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile [INFO] | +- org.springframework.data:spring-data-jpa:jar:2.0.9.RELEASE:compile

And using spring-data-jpa-entity-graph version 2.0.7.

I applied
@EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class)

And this is my UserRepository:
`
@repository
public interface UserRepository extends EntityGraphJpaRepository<User, Long> {

String USERS_BY_LOGIN_CACHE = "usersByLogin";

String USERS_BY_EMAIL_CACHE = "usersByEmail";

Optional<User> findOneByActivationKey(String activationKey);

List<User> findAllByActivatedIsFalseAndCreatedDateBefore(Instant dateTime);

Optional<User> findOneByResetKey(String resetKey);

Optional<User> findOneByEmailIgnoreCase(String email);

Optional<User> findOneByLogin(String login);

Optional<User> findOneById(Long id);

Optional<User> findOneWithAuthoritiesById(Long id, EntityGraph entityGraph);

@Cacheable(cacheNames = USERS_BY_LOGIN_CACHE)
Optional<User> findOneWithAuthoritiesByLogin(String login, EntityGraph entityGraph);

@Cacheable(cacheNames = USERS_BY_EMAIL_CACHE)
Optional<User> findOneWithAuthoritiesByEmail(String email, EntityGraph entityGraph);

Page<User> findAllByLoginNot(Pageable pageable, String login);

}
`

I would greatly appreciate any insight you might have.

spring-data-jpa-entity-graph-generator doesn't generate

Following documentation, I added the following dependencies.

    <dependency>
      <groupId>com.cosium.spring.data</groupId>
      <artifactId>spring-data-jpa-entity-graph</artifactId>
      <version>${spring-data-jpa-entity-graph.version}</version>
    </dependency>
    <dependency>
      <groupId>com.cosium.spring.data</groupId>
      <artifactId>spring-data-jpa-entity-graph-generator</artifactId>
      <version>${spring-data-jpa-entity-graph.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-jpamodelgen</artifactId>
      <scope>provided</scope>
    </dependency>

In my class, when I try to access the generated EntityGraph after compiling the project, the IDE cannot find such class. Is there something else I need to do?

image

Versions:

  • Spring Data JPA 2.2.7
  • spring-data-jpa-entity-graph 2.2.8
  • spring-data-jpa-entity-graph-generator 2.2.8
  • hibernate-jpamodelgen 5.4.15.Final

Extend documentation for @EnableJpaRepositories

Provide an additional example with basePackages in case if the configuration in a separate package.

@Configuration
@EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class, basePackages = "net.xxx.service.base")
public class DataRepositoryConfiguration {

}

Throw when using @Lock and default graph

What steps will reproduce the problem?

  1. Create custom jpa repository method and put @lock
@Lock(LockModeType.PESSIMISTIC_WRITE)
Optional<Person> findAndLockById(UUID id)
  1. Add field to Person
@OneToMany(mappedBy = "person", fetch = FetchType.LAZY)
private List<Address> addresses
  1. Add default graph to Person (Person.default) with
....
@NamedAttributeNode(address)
  1. Do query by findAndLockById

What is the expected output?
Find and lock without entity graph
What happens instead?

org.postgresql.util.PSQLException: ERROR: FOR UPDATE cannot be applied to the nullable side of an outer join

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.5.2
  • ORM with version: 5.6.1
  • spring-data-jpa-entity-graph version: 2.5.0

Is there some way not to use default entity graph for some jpa methods?

Use Specfications without extra join

hi
Thanks for your library that makes me very happy.
i have a question :
how to use Specfication without extra join (Join<x,y>) with our entityGraph?
in our namedEntityGraph actually we are joining Entities together and now i want to set where clause on the one of those subGraph to fetch with that.
is ther any way?
(sorry for my bad English)

findAll with pageable is not working well with entitygraphs

Hi, I have two entities, A has a @OneToMany relation to B. then i set entitygraph and expect to retrieve nested B in one SQL.

When i use findAll with pageable, it doesn’t do pagination, no limit is generated . instead it will load the whole table.

How to customize repository base class

This library is what I was looking for. Thanks!
However, I have a question.

How can I customize the repository base class?
I want to use the function of Spring official document "Adding custom behavior to all repositories".

@NoRepositoryBean
public interface MyRepository<T, ID extends Serializable>
    extends EntityGraphJpaRepository<T, ID> {
    // ...
}
@Configuration
@EnableJpaRepositories(
    repositoryBaseClass = MyRepositoryImpl.class,  // <-- customized base class!
    repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class
)
public class DataRepositoryConfiguration {
    //...
}

So, I'm thinking to inherit EntityGraphSimpleJpaRepository as follows.
But EntityGraphSimpleJpaRepository is not public...

public class MyRepositoryImpl<T, ID extends Serializable>
    extends EntityGraphSimpleJpaRepository<T, ID>
    implements MyRepository<T, ID> {
    // ...
}

Could you please support this?

Thanks.

NPE while using library

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. just try to use method like:
    final Optional applicationOpt =
    applicationRepository.findById(applicationUid, EntityGraphs.named(Application.SOME_GRAPH));

What is the expected output?
Should return result

What happens instead?
throws exception

Environment:

  • Spring Data JPA version (not the Spring Boot one): 2.3.4
  • ORM with version: 5.4.21
  • spring-data-jpa-entity-graph version: 2.3.4

Additional context
Repository definition

@Repository
public interface ApplicationRepository extends EntityGraphJpaSpecificationExecutor<Application>,
		EntityGraphCrudRepository<Application, String>, EntityGraphPagingAndSortingRepository<Application, String>,
		EntityGraphQuerydslPredicateExecutor<Application>, QuerydslBinderCustomizer<QApplication>

java.lang.NullPointerException: null
	at org.hibernate.loader.plan.build.internal.AbstractEntityGraphVisitationStrategy.startingCollectionIndex(AbstractEntityGraphVisitationStrategy.java:183) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCollectionIndex(MetamodelGraphWalker.java:245) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitCollectionDefinition(MetamodelGraphWalker.java:231) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAssociation(MetamodelGraphWalker.java:206) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributeDefinition(MetamodelGraphWalker.java:178) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributes(MetamodelGraphWalker.java:140) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitEntityDefinition(MetamodelGraphWalker.java:97) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAssociation(MetamodelGraphWalker.java:209) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributeDefinition(MetamodelGraphWalker.java:178) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitAttributes(MetamodelGraphWalker.java:140) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitEntityDefinition(MetamodelGraphWalker.java:97) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.walking.spi.MetamodelGraphWalker.visitEntity(MetamodelGraphWalker.java:56) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.plan.build.spi.MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan(MetamodelDrivenLoadPlanBuilder.java:39) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.<init>(AbstractLoadPlanBasedEntityLoader.java:96) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.<init>(AbstractLoadPlanBasedEntityLoader.java:112) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:125) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:38) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.EntityLoader$Builder.byUniqueKey(EntityLoader.java:90) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.EntityLoader$Builder.byPrimaryKey(EntityLoader.java:83) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.plan.AbstractBatchingEntityLoaderBuilder.buildNonBatchingLoader(AbstractBatchingEntityLoaderBuilder.java:39) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.loader.entity.BatchingEntityLoaderBuilder.buildLoader(BatchingEntityLoaderBuilder.java:98) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2572) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.getAppropriateLoader(AbstractEntityPersister.java:4543) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:4417) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4408) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:569) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:537) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:208) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:332) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:108) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:74) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:113) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1187) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1176) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl.access$2100(SessionImpl.java:194) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2787) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.lambda$load$1(SessionImpl.java:2768) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.perform(SessionImpl.java:2724) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2768) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3323) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3290) ~[hibernate-core-5.4.21.Final.jar:5.4.21.Final]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:314) ~[spring-orm-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at com.sun.proxy.$Proxy236.find(Unknown Source) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryEntityManagerEntityGraphInjector.invoke(RepositoryEntityManagerEntityGraphInjector.java:66) ~[spring-data-jpa-entity-graph-2.3.1.jar:?]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at com.sun.proxy.$Proxy238.find(Unknown Source) ~[?:?]
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById(SimpleJpaRepository.java:281) ~[spring-data-jpa-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at com.cosium.spring.data.jpa.entity.graph.repository.support.EntityGraphSimpleJpaRepository.findById(EntityGraphSimpleJpaRepository.java:72) ~[spring-data-jpa-entity-graph-2.3.1.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at org.springframework.data.repository.core.support.ImplementationInvocationMetadata.invoke(ImplementationInvocationMetadata.java:72) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:382) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:205) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:549) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:155) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) ~[spring-tx-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) ~[spring-tx-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:161) ~[spring-data-jpa-entity-graph-2.3.1.jar:?]
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:105) ~[spring-data-jpa-entity-graph-2.3.1.jar:?]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:178) ~[spring-data-jpa-2.3.4.RELEASE.jar:2.3.4.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.9.RELEASE.jar:5.2.9.RELEASE]
	at com.sun.proxy.$Proxy243.findById(Unknown Source) ~[?:?]
	at com.xxx.apps.service.ApplicationService.getSomeCollection(ApplicationService.java:356) ~[classes/:?]

Getting Started

I have followed [2.0 quickstart guide](https://github.com/Cosium/spring-data-jpa-entity-graph/blob/master/doc/MAIN.md,

In my database configuration I had:

@Configuration
@EnableJpaRepositories("com.mypackage.api.repository")
@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware")
@EnableTransactionManagement
@EnableElasticsearchRepositories("com.mypackage.api.repository.search")
public class DatabaseConfiguration {
    @Bean
    public Hibernate5Module hibernate5Module() {
        return new Hibernate5Module();
    }
}

Now if I switch:

@EnableJpaRepositories("com.mypackage.api.repository")

to:

@EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class)

I than add a new repository:

public interface UserEntityGraphRepository extends EntityGraphJpaRepository<User, Long> {
}

in addition to:

public interface UserRepository extends JpaRepository<User, Long> {
}

I get exception:

java.lang.IllegalStateException: Failed to load ApplicationContext
...
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type User!

If I just replace extends JpaRepository w/ EntityGraphJpaRepository, I get:

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property findOne found for type User!

Multiple/Default EntityGraphs

Hey! Is it currently possible to set the default entity graph and then have any DynamicEntityGraph's just add attributes on top of the default.

I have a scenario where I'd like certain fields in an Entity to always be Fetched and then be able to choose what other fields using the EntityGraph supplied!

NoSuchMethodError on Spring Boot 2.3.10

Version:

  • Spring Boot: 2.3.10
  • spring-data-jpa-entity-graph: 2.3.1

After upgrading from Spring Boot 2.3.7 to 2.3.10, I got the following exception executing a query with entity graph.

org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.jpa.repository.query.Jpa21Utils.getFetchGraphHint(Ljavax/persistence/EntityManager;Lorg/springframework/data/jpa/repository/query/JpaEntityGraph;Ljava/lang/Class;)Lorg/springframework/data/jpa/repository/support/QueryHints;
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1055)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at brave.servlet.TracingFilter.doFilter(TracingFilter.java:68)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.AbstractRequestLoggingFilter.doFilterInternal(AbstractRequestLoggingFilter.java:289)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
	at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
	at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at brave.servlet.TracingFilter.doFilter(TracingFilter.java:87)
	at org.springframework.cloud.sleuth.instrument.web.LazyTracingFilter.doFilter(TraceWebServletAutoConfiguration.java:141)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.springframework.data.jpa.repository.query.Jpa21Utils.getFetchGraphHint(Ljavax/persistence/EntityManager;Lorg/springframework/data/jpa/repository/query/JpaEntityGraph;Ljava/lang/Class;)Lorg/springframework/data/jpa/repository/support/QueryHints;
	at com.cosium.spring.data.jpa.entity.graph.repository.support.QueryHintsUtils.buildQueryHints(QueryHintsUtils.java:41)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryQueryEntityGraphInjector.addEntityGraphToQuery(RepositoryQueryEntityGraphInjector.java:91)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryQueryEntityGraphInjector.invoke(RepositoryQueryEntityGraphInjector.java:72)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy348.getResultList(Unknown Source)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:126)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:88)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:154)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:142)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.doInvoke(RepositoryMethodEntityGraphExtractor.java:158)
	at com.cosium.spring.data.jpa.entity.graph.repository.support.RepositoryMethodEntityGraphExtractor$JpaEntityGraphMethodInterceptor.invoke(RepositoryMethodEntityGraphExtractor.java:102)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:149)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
	at com.sun.proxy.$Proxy220.findDeploymentsWithinRange(Unknown Source)
	at com.ft.common.modules.data.service.DeploymentModule.lambda$14(DeploymentModule.java:290)
	at com.ft.common.api.utils.AsyncUtils.splitCallAndThenCollect(AsyncUtils.java:190)
	at com.ft.common.api.utils.AsyncUtils.splitCallAndThenApply(AsyncUtils.java:159)
	at com.ft.common.api.utils.AsyncUtils.splitCallAndThenFlatten(AsyncUtils.java:145)
	at com.ft.common.modules.data.service.DeploymentModule.findTempDeploymentsWithinRange(DeploymentModule.java:289)
	at com.ft.common.modules.data.service.DeploymentModule$$FastClassBySpringCGLIB$$22bace57.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
	at com.ft.common.modules.data.service.DeploymentModule$$EnhancerBySpringCGLIB$$3c868139.findTempDeploymentsWithinRange(<generated>)
	at com.ft.demo.controller.TestController.test(TestController.java:83)
	at com.ft.demo.controller.TestController$$FastClassBySpringCGLIB$$cc364628.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)
	at com.ft.common.modules.audit.core.AuditAspect.audit(AuditAspect.java:101)
	at com.ft.common.modules.audit.core.AuditAspect.performAudit(AuditAspect.java:80)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)
	at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691)
	at com.ft.demo.controller.TestController$$EnhancerBySpringCGLIB$$85414548.test(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
	... 87 more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.