org.hibernate.MappingException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Appears to be an inconsistency between org.hibernate.ejb.criteria.path.PluralAttributePath#resolveRole and naming of CollectionPersisters org.hibernate.MappingException: Unknown collection role: test.BookDefinition.bookMarks at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:162) at test.Test.testTestSystem(Test.java:136) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:60) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:106) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111) 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) ... Removed 26 stack frames Click to hide stack frames org.hibernate.MappingException: Unknown collection role: test.BookDefinition.bookMarks at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:162) at test.Test.testTestSystem(Test.java:136) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76) at org.testng.internal.Invoker.invokeMethod(Invoker.java:673) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:1147) at org.testng.TestRunner.privateRun(TestRunner.java:749) at org.testng.TestRunner.run(TestRunner.java:600) at org.testng.SuiteRunner.runTest(SuiteRunner.java:317) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274) at org.testng.SuiteRunner.run(SuiteRunner.java:223) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039) at org.testng.TestNG.runSuitesLocally(TestNG.java:964) at org.testng.TestNG.run(TestNG.java:900) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:60) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:106) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111) 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)
    via by Paul Nardone,
  • Appears to be an inconsistency between org.hibernate.ejb.criteria.path.PluralAttributePath#resolveRole and naming of CollectionPersisters org.hibernate.MappingException: Unknown collection role: test.BookDefinition.bookMarks at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:162) at test.Test.testTestSystem(Test.java:136) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:60) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:106) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111) 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) ... Removed 26 stack frames Click to hide stack frames org.hibernate.MappingException: Unknown collection role: test.BookDefinition.bookMarks at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:162) at test.Test.testTestSystem(Test.java:136) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76) at org.testng.internal.Invoker.invokeMethod(Invoker.java:673) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:1147) at org.testng.TestRunner.privateRun(TestRunner.java:749) at org.testng.TestRunner.run(TestRunner.java:600) at org.testng.SuiteRunner.runTest(SuiteRunner.java:317) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274) at org.testng.SuiteRunner.run(SuiteRunner.java:223) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1039) at org.testng.TestNG.runSuitesLocally(TestNG.java:964) at org.testng.TestNG.run(TestNG.java:900) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:60) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:106) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111) 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)
    via by Paul Nardone,
  • I'm trying to get the PluralAttributePath from a collection defined in a MappedSuperclass {code} @Entity public class Person extends PersonBase { @Basic private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } {code} {code} @MappedSuperclass public abstract class PersonBase { @Id private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } @OneToMany() private Set<Address> addresses = new HashSet<Address>(); public Set<Address> getAddresses() { return addresses; } public void setAddresses(Set<Address> addresses) { this.addresses = addresses; } } {code} Executing the following {code} criteriaQuery = criteriaBuilder.createQuery(Person.class); root = criteriaQuery.from(Person.class); Path<?> pathAddresses = root.get("addresses"); {code} throws the exception {noformat} org.hibernate.MappingException: Unknown collection role: testcase.hibernate.PersonBase.addresses at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:157) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:197) at testcase.hibernate.HibernateTest.testMappedSuperclassPluralAttribute(HibernateTest.java:53) {noformat}
    via by Oliver Ringel,
  • I'm trying to get the PluralAttributePath from a collection defined in a MappedSuperclass {code} @Entity public class Person extends PersonBase { @Basic private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } {code} {code} @MappedSuperclass public abstract class PersonBase { @Id private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } @OneToMany() private Set<Address> addresses = new HashSet<Address>(); public Set<Address> getAddresses() { return addresses; } public void setAddresses(Set<Address> addresses) { this.addresses = addresses; } } {code} Executing the following {code} criteriaQuery = criteriaBuilder.createQuery(Person.class); root = criteriaQuery.from(Person.class); Path<?> pathAddresses = root.get("addresses"); {code} throws the exception {noformat} org.hibernate.MappingException: Unknown collection role: testcase.hibernate.PersonBase.addresses at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:157) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:197) at testcase.hibernate.HibernateTest.testMappedSuperclassPluralAttribute(HibernateTest.java:53) {noformat}
    via by Oliver Ringel,
  • I use an <sql-query> for a <loader> in a collection owned by a named entity. The role attribute is set to "<entity-name>.<property-name>" - exactly the key under witch the collection's meta data is registered in SessionFactoryImpl.collectionPersisters map - but when the query is being added, SessionFactoryImpl looks for it under the key "<package>.<entity-name>.<property-name>" in this map, and doesn't find it. When entity-name attribute is removed from the entity mapping and unqualified class name is used to refer to it instead, everything works fine. The easiest, and probably most uniform solution would be to introduce a second attribute "entity-role" to the load-collection element. The following exception results from mapping: <hibernate-mapping package="hibernatedemo.model"> .... <class table="persons_test" entity-name="person" name="Person"> .... <set name="personMap" inverse="true"> <key/> <one-to-many entity-name="person_map"/> <loader query-ref="fetch_person_map_by_person"/> </set> </class> <sql-query name="fetch_person_map_by_person"> <load-collection alias="map" role="person.personMap" /> select {map.*} from persons_map_test map where map.person_id=:id </sql-query> org.hibernate.MappingException: Unknown collection role: hibernatedemo.model.person.personMap at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:558) at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.addCollection(SQLQueryReturnProcessor.java:370) at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processCollectionReturn(SQLQueryReturnProcessor.java:405) at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.processReturn(SQLQueryReturnProcessor.java:335) at org.hibernate.loader.custom.sql.SQLQueryReturnProcessor.process(SQLQueryReturnProcessor.java:148) at org.hibernate.loader.custom.sql.SQLCustomQuery.<init>(SQLCustomQuery.java:64) at org.hibernate.engine.query.NativeSQLQueryPlan.<init>(NativeSQLQueryPlan.java:43) at org.hibernate.engine.query.QueryPlanCache.getNativeSQLQueryPlan(QueryPlanCache.java:114) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:446) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:352) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300) at hibernatedemo.Test.getHibernateSession(Test.java:44) at hibernatedemo.Test.main(Test.java:25) 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:324) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
    via by Marcin Mościcki,
    • org.hibernate.MappingException: Unknown collection role: test.BookDefinition.bookMarks at org.hibernate.impl.SessionFactoryImpl.getCollectionPersister(SessionFactoryImpl.java:701) at org.hibernate.ejb.criteria.path.PluralAttributePath.resolvePersister(PluralAttributePath.java:58) at org.hibernate.ejb.criteria.path.PluralAttributePath.<init>(PluralAttributePath.java:52) at org.hibernate.ejb.criteria.path.AbstractPathImpl.get(AbstractPathImpl.java:162) at test.Test.testTestSystem(Test.java:136) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:60) at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:106) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:111) 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)
    No Bugmate found.