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.  [ 2 posts ] 
Author Message
 Post subject: problem in optimistic lock implementation
PostPosted: Thu Jul 06, 2006 8:22 am 
Newbie

Joined: Tue Feb 07, 2006 2:02 am
Posts: 12
Hi...

There is a problem in optimistic lock implementation...

I have this entry in my mapping file

<class name="SalesDetails" table="SALES_DETAILS" optimistic-lock="version">

and the timestamp field is:

<timestamp column="LAST_UPDATE_DATE" name="lastUpdateDate" unsaved-value="undefined"/>

The behavior observed in the application is that when we try to update the record using saveOrUpdate method it attempts to insert though the primary key value is provided...

Please let me know if any mapping i m missing or where i am going wrong....

_________________
Regards
.....Hiisi.....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 10:19 am 
Beginner
Beginner

Joined: Mon Jan 23, 2006 12:01 pm
Posts: 46
Hi,

I'm not sure if this will help, but maybe you could try to test your code in a simple program, like this:

Session s=//get Hibernate session
Criteria c=s.createCriteria(Object.class);

//pk is whatever the key is for your table, 'key' is a valid key
c.add(Expression.eq("pk",key));

Object object=c.list().iterator().next();

object.setWhatever(...);//update something
s.update(object);
s.flush();

If this simple code works, it could be that you're closing Hibernate session somewhere in your original code, and then you re-open it, so the object reference is not in session (primary key will not help you then), so Hibernate thinks it's an insert.

HTH,

Bratek


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.