-->
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: optimistic locking and evict
PostPosted: Wed Oct 27, 2004 11:08 pm 
Newbie

Joined: Tue Sep 28, 2004 7:14 pm
Posts: 7
I'm using hibernate 2.1 in the context of JTA transactions. I've enabled optimistic locking by timestamp. If I use the following jag of code to save, then I get stale object exceptions on subsequent saves in later transactions.

Code:
    session = factory.openSession();
    tx = session.beginTransaction();

    session.save(order);
    session.flush();
    tx.commit();

    session.close();



However, when I evict and reload subsequent saves occur without error.

Code:
    session = factory.openSession();
    tx = session.beginTransaction();

    session.save(order);
    session.flush();
    session.evict(order);
    order = (Order) session.load(order.getClass(), new Long(order.getWebOrderId()));
    tx.commit();

    session.close();


I hardly think that the evict and reload should be required. The timestamps seem to be getting set in both the entities and the database. Anyone have any ideas what I may be doing wrong?


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