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
|