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.  [ 1 post ] 
Author Message
 Post subject: JPA @Version problem (dirty context?)
PostPosted: Tue Jun 09, 2009 4:41 pm 
Newbie

Joined: Thu Jan 24, 2008 5:59 pm
Posts: 2
I am calling persist on my entity which results in the correct insert statements, but then at the end of the transaction, a mysterious update is called which bumps up the @Version number. Since I copy the the entity to a DTO before the transaction is complete, the returned DTO has an older version number which is causing optimistic locking problems.

In the log I noticed that hibernate does something called "dirty checking collections" right before this update.

My Entity beans are all annotated on the property level, but I do have convenience getter methods for collections which are like this:
List getMyList(){
if(myList==null){
myList=newArrayList();
}
return myList;
}

could this be cause of the problem? Would it be advisable to not do any custom get methods?
Thanks,
Daniel


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

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.