Getting following exception while running a test Spring Hibernate Application :
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.testapp.service.profiles.MGProfile; nested exception is org.hibernate.MappingException: Unknown entity: com. testapp.service.profiles.MGProfile
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.testapp.service.profiles.MGProfile; nested exception is org.hibernate.MappingException: Unknown entity: com. testapp.service.profiles.MGProfile
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:690)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:512)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:506)
at com. testapp.service.profiles.MGProfileDao.getMGProfile(MGProfileDao.java:49)
at org.mg.service.SpringHibernateTest.main(SpringHibernateTest.java:41)
Caused by: org.hibernate.MappingException: Unknown entity: com. testapp.service.profiles.MGProfile
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:693)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1005)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:998)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:519)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
... 5 more
Resolved By Putting Following on top of Entity Class :
ReplyDelete@Entity
@Table(name = "MGProfile")
@XmlRootElement