i run out the following problem: want to read to different objects from different tables.
Code:
// get session
// begin transaction....
Users creator = (Users)getSession().createCriteria(Users.class).add(Expression.like("userId", 2)).list().get(0);
State state = (State)getSession().createCriteria(State.class).add(Expression.like("stateId", 20)).list().get(0);
DocumentTypes typ = (DocumentTypes)getSession().createCriteria(DocumentTypes.class).add(Expression.like("doctypesId", 0)).list().get(0);
// commit...
to get creator works fine. but when i read from state table i get:
Code:
org.hibernate.HibernateException: identifier of an instance of at.plot.profit.persist.objects.database.Users was altered from 2 to 2
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:58)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:157)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1562)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at at.plot.profit.persist.java.contextworker.ContextWorkerDocuments.handleDataBefore(ContextWorkerDocuments.java:26)
at at.plot.profit.persist.java.PersistManager.handleContext(PersistManager.java:233)
at at.plot.profit.persist.java.PersistManager.handleContext(PersistManager.java:271)
at at.plot.profit.persist.java.PersistManager.operate(PersistManager.java:178)
at at.plot.profit.persist.java.PersistManager.operate(PersistManager.java:208)
at at.plot.profit.persist.java.PersistManager.main(PersistManager.java:372)
but i do not change the user object in no way. why that behaviour? also very interesting is, that it is called that user change from 2 to 2!!!