hi,
I got a concurrent problem about hibernate3.0
I use <timestamp name="lastDate" column="LAST_DATE"/> as concurrent control
following is my program:
public void save(Object entry)
{
Session session=getSession();
Transaction transaction=session.beginTransaction();
try
{
System.out.println(entry.getLastDate());
session.update(entry);
transaction.commit();
}
catch(Exception e)
{
transaction.rollback();
}
session.close();
}
in normal case, it can work fine, when there is an exception(for example unique checking) occured when "session.update(entry);" the transaction will rollback. after I modify "entry" and call this method to update it into database, I always got a concurrent exception (this object has been updated by other session), but it is impossible because nobody will change this entry
and I found the timestamp column - lastDate has been modified when commit, and do not rollback when the whole transaction been rollback. that's why I always get concurrent exception.
how can I do now? is it a bug of hibernate?
thanks a lot
regards
Simon
|