Announcement Announcement Module
Collapse
No announcement yet.
Spring data JPA with hibernate: Error "No property find found" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring data JPA with hibernate: Error "No property find found"

    Hello,

    I am trying to build a web application, where the data layer is built with Spring data JPA and Hibernate.
    Everything works fine until I activate Auditing with Envers.

    I created a new github project with just the basic technologies, so you can hopefully reproduce the error easily (and help me out).

    My complete source code can be found here:
    https://github.com/gene-oregami/jpa-audit-test

    This is the error I get while starting the JUnit test "TestSaveEntity".

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.oregami.test.TestSaveEntity': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.oregami.jpa.IFirstEntityRepository org.oregami.test.TestSaveEntity.firstEntityRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iFirstEntityRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property find found for type org.oregami.entities.FirstEntity
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:379)
    	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
    	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
    	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:313)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    	at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    	at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.oregami.jpa.IFirstEntityRepository org.oregami.test.TestSaveEntity.firstEntityRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iFirstEntityRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property find found for type org.oregami.entities.FirstEntity
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
    	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
    	... 27 more
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'iFirstEntityRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property find found for type org.oregami.entities.FirstEntity
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1443)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:249)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:873)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:815)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:730)
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
    	... 29 more
    Caused by: org.springframework.data.mapping.PropertyReferenceException: No property find found for type org.oregami.entities.FirstEntity
    	at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:74)
    	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:326)
    	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:352)
    	at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:306)
    	at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)
    	at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:244)
    	at org.springframework.data.repository.query.parser.Part.<init>(Part.java:73)
    	at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180)
    	at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260)
    	at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240)
    	at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68)
    	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:57)
    	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90)
    	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162)
    	at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:280)
    	at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:148)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:125)
    	at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:41)
    	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
    	... 37 more
    Thanks in advance!

  • #2
    Does the exlude-unlisted-classes in your xml file have Hibernate scan for @Entity. The docs always confused me. Maybe adding envers made that stop.

    Also, a side note. Do you actually want a public method to set the ID. This opens up the ability to change the ID, and your Id is set to @GeneratedValue

    I would remove the setId method.

    public void setId(Long id) {
    this.id = id;
    }

    Mark

    Comment


    • #3
      Hi Mark,
      thanks for your reply.

      I removed the file "persistence.deploy.xml", because it isn't used at all. So the "exlude-unlisted-classes" doesn't mean anything here

      I also removed the setId-method, thanks for the hint.


      Nevertheless, I still get the annoying error "No property find found for type org.oregami.entities.FirstEntity"

      Comment


      • #4
        RevisionRepository maybe, might have added a method that the Spring Data JPA thinks is a derived query looking for a property called "find"???

        Out of humor, I wonder what happens if you added a field/property in FirstEntity say private String find; and see if that removes the exception. Just to see if my first paragraph in this post might be correct. Of course, you don't really want a property called "find".

        Mark

        Comment


        • #5
          Basically, today myself, I found that the "scan" of repositories and methods in them is very "open" in Spring Data, which can sometimes cause issues if you name a method like a derived query, but never meant it to be. There are many conventions in Spring Data, and you have to make sure you follow them for what you want Spring Data to do and not introduce stuff that it will do, that you didn't want it to do. (Not a knock, just a be aware thing)

          Like I just found out today that in the xml or Annotations for <jpa:repositories> or @EnableJpaRepositories accepts include and exclude filters.

          Mark

          Comment

          Working...
          X