Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Started #15

Closed
jordanbaucke opened this issue Oct 31, 2017 · 9 comments
Closed

Getting Started #15

jordanbaucke opened this issue Oct 31, 2017 · 9 comments
Labels

Comments

@jordanbaucke
Copy link

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!

@reda-alaoui
Copy link
Member

Your issue looks like #8
Are you certain that @EnableJpaRepositories(repositoryFactoryBeanClass = EntityGraphJpaRepositoryFactoryBean.class) was taken into account?

Can you put a breakpoint in the factoryBean class to check it is the one that is used?

Also can I see the User class?
And could you try to disable Elasticsearch and/or Auditing to see if the issue could come from here?

@jordanbaucke
Copy link
Author

@reda-alaoui which factory bean class?

@reda-alaoui
Copy link
Member

EntityGraphJpaRepositoryFactoryBean

@jordanbaucke
Copy link
Author

jordanbaucke commented Oct 31, 2017

@reda-alaoui

Here is User Class (relevant parts at least)
https://gist.github.com/jordanbaucke/125f7a47eb224aeeb25d4b40ecf41f6e,

And current UseRepository:
https://gist.github.com/jordanbaucke/7b14b3c939774b59063d980feb191016

I do not get to loading EntityGraphJpaRepositoryFactoryBean, as SpringSecurity kicks in and throws:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataInitalizer': Unsatisfied dependency expressed through field 'dataInitializationService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataInitializationServiceImpl': Unsatisfied dependency expressed through field 'passwordEncoder'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception is 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 getOne found for type User!

2017-10-31_11-52-18

@reda-alaoui
Copy link
Member

reda-alaoui commented Oct 31, 2017

I see a compilation error inside the dependency.
What version of Spring Data are you using?
Can you paste the relevant pom.xml or gradle files parts?

@jordanbaucke
Copy link
Author

  compile "org.springframework.boot:spring-boot-starter-data-jpa"
...
    compile "com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0"

??

@reda-alaoui
Copy link
Member

I need to know which version of https://github.com/spring-projects/spring-data-jpa you are using.

@jordanbaucke
Copy link
Author

jordanbaucke commented Oct 31, 2017

Sorry:

Appears to be org.springframework.data:spring-data-jpa:1.10.5.RELEASE, so I should change my version of com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0

~/Documents/workspace/api$ gradle dependencies | grep spring-data
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
\--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0
|    +--- org.springframework.data:spring-data-jpa:1.10.5.RELEASE
|    |    +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE
|    \--- org.springframework.data:spring-data-elasticsearch:2.0.5.RELEASE
|         +--- org.springframework.data:spring-data-commons:1.12.5.RELEASE (*)
|    +--- org.springframework.data:spring-data-commons:1.12.2.RELEASE -> 1.12.5.RELEASE (*)
+--- com.cosium.spring.data:spring-data-jpa-entity-graph:2.0.0

@reda-alaoui
Copy link
Member

Yes you must use a 1.10.x version of this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants