-->
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 using timestamp
PostPosted: Tue Oct 26, 2004 3:14 pm 
Beginner
Beginner

Joined: Tue Jun 22, 2004 3:16 pm
Posts: 35
Hi, I am trying to use optimistic locking with timestamp. I followed example from the book and I could not get that work. I don't see the StaleObjectStateException been thrown.

I have this in mapping file:

<timestamp
column="LAST_MODIFIED_DATE"
name="lastModifiedDate"
/>

and this maps a column of database table, LAST_MODIFIED_DATE, which the type is Date (Oracle 9i).

In POJO code, I have:

private Date lastModifiedDate;

public Date getLastModifiedDate() {
return lastModifiedDate;
}

public void setLastModifiedDate(Date lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}

Then from my Web app, I have two browsers up running in two PCs. I update the same object in the following order:
1) user1 get BBB
2) user2 get BBB
3) user1 update BBB
4) user2 update BBB

From console, I see:

update TBL_BBB set LAST_MODIFIED_DATE=?, EMAIL=? where PK_BBB_ID=? and LAST_MODIFIED_DATE=?

The database gets updated and reflect the user2's input. I did not get any exception.

ANything wrong here?

Thanks,

J


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.