Strange properyname in errormessage releated to @ManyToMany mappedBy
--------------------------------------------------------------------
Key: HHH-6926
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6926
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Final
Reporter: Kaj Hejer
We get the following errormessage when starting our application:
{code}
property-ref [_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
{code}
BUT! The propertyname used in @ManyToMany mappedBy is "bs", not
"_no_uio_webapps_minestudiermed_domain_base_A_bs".
This issue is also described at
http://stackoverflow.com/questions/3637956/hibernate-failing-by-prependin...
We have the following classes:
Class A:
{code}
@Entity
public class A implements Serializable {
@Id
@Column(name = "resources_id")
public Long id;
@ManyToMany
@JoinTable(name = "RESOURCES_LESSON", joinColumns = @JoinColumn(name =
"resources_id", referencedColumnName = "resources_id", insertable =
false, updatable = false, nullable = true), inverseJoinColumns = @JoinColumn(name =
"kode_fs", referencedColumnName = "kode_fs", nullable = true))
private Set<B> bs = new HashSet<B>();
public Long getId() {
return id;
}
public void setId(final Long id) {
this.id = id;
}
public Set<B> getBs() {
return bs;
}
public void setBs(final Set<B> bs) {
this.bs = bs;
}
}
{code}
Class B:
{code}
@Entity
public class B implements Serializable {
@Id
@Column(name = "ID_FS")
private String idFs;
@Column(name = "KODE_FS")
private Long codeFs;
@ManyToMany(mappedBy = "bs")
private Set<A> as = new HashSet<A>();
public String getIdFs() {
return idFs;
}
public void setIdFs(final String idFs) {
this.idFs = idFs;
}
public Set<A> getAs() {
return as;
}
public void setAs(final Set<A> as) {
this.as = as;
}
public Long getCodeFs() {
return codeFs;
}
public void setCodeFs(final Long codeFs) {
this.codeFs = codeFs;
}
}
{code}
We are using Hibernate 4.0.0.Final and Spring 3.1.0.RELEASE.
Full stacktrace:
{code}
java.lang.IllegalStateException: Failed to load ApplicationContext
at
org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
at
org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:109)
at
org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at
org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
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:15)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:290)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
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:300)
at
org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35)
at
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:115)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at
org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at
org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'accountancyDAO': Injection of autowired dependencies failed; nested
exception is org.springframework.beans.factory.BeanCreationException: Could not autowire
field: private org.hibernate.SessionFactory
no.uio.webapps.minestudiermed.dao.GenericDAOImpl.sessionFactory; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sessionFactory' defined in URL
[file:src/main/resources/META-INF/spring/applicationContext.xml]: Invocation of init
method failed; nested exception is org.hibernate.MappingException: property-ref
[_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at
org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:103)
at
org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
at
org.springframework.test.context.support.DelegatingSmartContextLoader.loadContext(DelegatingSmartContextLoader.java:228)
at
org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:124)
at
org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:148)
... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire
field: private org.hibernate.SessionFactory
no.uio.webapps.minestudiermed.dao.GenericDAOImpl.sessionFactory; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'sessionFactory' defined in URL
[file:src/main/resources/META-INF/spring/applicationContext.xml]: Invocation of init
method failed; nested exception is org.hibernate.MappingException: property-ref
[_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at
org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
... 45 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'sessionFactory' defined in URL
[file:src/main/resources/META-INF/spring/applicationContext.xml]: Invocation of init
method failed; nested exception is org.hibernate.MappingException: property-ref
[_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
... 47 more
Caused by: org.hibernate.MappingException: property-ref
[_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
at
org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:371)
at
org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1613)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1359)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1724)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1775)
at
org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:184)
at
org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:314)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 57 more
Caused by: org.hibernate.MappingException: property
[_no_uio_webapps_minestudiermed_domain_base_A_bs] not found on entity
[no.uio.webapps.minestudiermed.domain.base.A]
at
org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:428)
at
org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:368)
... 65 more
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira