Hello Hibernate Users,
I am upgrading my legacy application from Hibernate 3.6 to 4.3. The application works fine with Hibernate 3.6. However after I upgraded application to Hibernate 4.3 I am experiencing org.hibernate.MappingException: Unknown entity: java.util.HashSet. The exception is caused on calling getHibernateTemplate().saveOrUpdate(collection); where collection is a Set of entities that application is looking to save.
The mapping configuration of these entities in the application has not undergone any change and is same as before, so I am unable to realize what is going wrong now. The application is using Spring 4.1 and Java 8 and MS SQL 2014 is the database.
Any help/pointers to help resolve the issue is appreciated.
Regards,
Nitin
Below is the stacktrace for the Exception raised.
Code:
org.springframework.orm.hibernate4.HibernateSystemException: Unknown entity: java.util.HashSet; nested exception is org.hibernate.MappingException: Unknown entity: java.util.HashSet
at org.springframework.orm.hibernate4.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:218)
at org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:343)
at org.springframework.orm.hibernate4.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:308)
at org.springframework.orm.hibernate4.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:681)
at com.mycompany.rm.pmech.common.dao.GenericDAO.saveOrUpdateAll(GenericDAO.java:408)
at com.mycompany.rm.pmech.pricingprogram.service.impl.PricingGridServiceImpl.saveLinks(PricingGridServiceImpl.java:318)
at com.mycompany.rm.pmech.pricingprogram.service.impl.PricingGridServiceImpl.saveAndPropagateLinks(PricingGridServiceImpl.java:281)
at com.mycompany.rm.pmech.pricingprogram.service.impl.PricingGridServiceImpl.createLink(PricingGridServiceImpl.java:235)
at com.mycompany.rm.pmech.pricingprogram.service.impl.CopyNodeJobServiceImpl.performGridLinkingForNode(CopyNodeJobServiceImpl.java:498)
at com.mycompany.rm.pmech.pricingprogram.service.impl.CopyNodeJobServiceImpl.performGridLinking(CopyNodeJobServiceImpl.java:473)
at com.mycompany.rm.pmech.pricingprogram.service.impl.CopyNodeJobServiceImpl.performLinking(CopyNodeJobServiceImpl.java:324)
at com.mycompany.rm.pmech.pricingprogram.service.impl.CopyNodeJobServiceImpl.copyNode(CopyNodeJobServiceImpl.java:109)
at com.mycompany.rm.pmech.pricingprogram.service.impl.CopyNodeJobServiceImplTest.testCopyNodeAtPGLevelWithX502LinkageWhenTargetSeasonHasNoChildrenShouldSucceed(CopyNodeJobServiceImplTest.java:463)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:79)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
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.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.extensions.cpsuite.ClasspathSuite.run(ClasspathSuite.java:194)
at org.junit.runners.Suite.runChild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
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.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: org.hibernate.MappingException: Unknown entity: java.util.HashSet
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1443)
at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:242)
at org.hibernate.event.internal.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:511)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:100)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:671)
at org.springframework.orm.hibernate4.HibernateTemplate$16.doInHibernate(HibernateTemplate.java:685)
at org.springframework.orm.hibernate4.HibernateTemplate.doExecute(HibernateTemplate.java:340)
... 51 more