org.springframework.orm.hibernate3.HibernateSystemException: identifier of

异常如下:
Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: identifier of an instance of com.tarena.entity.User was altered from 1 to 1; nested exception is org.hibernate.HibernateException: identifier of an instance of com.tarena.entity.User was altered from 1 to 1
Caused by: org.hibernate.HibernateException: identifier of an instance of com.zhssh.vo.TUser was altered from 1 to 1
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:51)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:390)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:832)
at com.zhssh.spring.dao.TUserDAO.findAll(TUserDAO.java:113)
at com.zhssh.spring.dao.test.TUserDAOTest.main(TUserDAOTest.java:25)

原因: hbm里面id的type和java文件里面的不一样!

你可能感兴趣的:(Hibernate)