-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: two queries -> instance was altered
PostPosted: Mon Jan 22, 2007 9:24 am 
Newbie

Joined: Wed Jan 10, 2007 7:49 am
Posts: 4
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!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 9:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Check that you getters and setters are all correct (and not cross writing data), eg a copy and paste error.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 23, 2007 12:54 am 
Newbie

Joined: Wed Jan 10, 2007 7:49 am
Posts: 4
thx david for your reply.

checked all getter / setters like you told and really, it was my fault. the ID of Users was everywhere(database / pojo) a long, but in mapping file a int was entered.

it is a very hard to understand error message because i had already some incompatible getter / setter, but in that cases the error message was very clear, but here i tought the problem is anywhere else.

no matter ... it works fine and it was my fault.

thx very much.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.