This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LockMode.UPGRADE produces false sql ?

 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to lock a record via JPA/Hibernate.

I use the actual version of Hibernate and actual DB2-Database.

I will lock a record of type User:



The Hibernate-API says:




but I cannot find any "select..for update"-clause in this sql which was generated after declaring LockMode.UPGRADE:



Why does Hibernate not produce this:




What is false? (My Database DB2 uses Cursor Stability (CS)), but hibernate overwrite this with ISOLATION(RS).


 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Select ... for update" is Oracle syntax. Does DB2 support it?
 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

yes, DB2 supports it:

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/db2/rbafzmstintsel.htm (look for "update-clause")
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like a bug.
 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what a pitty,

issue created at 20/Feb/06.. a FOUR Years old bug for such a common thing?!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dunno - pessimistic locking and DB2 doesn't sound like that common a mixture to me. But annoying if you need it, I agreee!

You could always revert to a SQL query.
 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
however, thanks.


pessimistic locking and DB2 doesn't sound like that common a mixture to me


why?

I only want to lock records for update, so that other processes are not able do an update while I am working with that records.
I am working with that records and after the work is done, I will update it (and then it will be unlocked) - is that not common?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is in my experience. 14 years a developer writing a whole range of applications in a wide range of technologies (all database backed) and I've only once had to use pessimistic locking. And as for DB2 - outside its mainframe market (which is a whole different beast) - its market share is pretty small I understand.

The reason people tend not to use pessimistic locking is because it introduces a bottleneck into their application and it usually takes a really compelling reason to introduce a bottleneck.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic