-->
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.  [ 9 posts ] 
Author Message
 Post subject: Is the object lock by an other user?
PostPosted: Tue Nov 23, 2004 11:18 am 
Newbie

Joined: Tue Nov 23, 2004 11:07 am
Posts: 7
Location: Switzerland
Hibernate version:
2.1.4

Hello,

Is there possible to know if an object ist currently used by another person ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 23, 2004 11:46 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What?

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 23, 2004 11:54 am 
Newbie

Joined: Tue Nov 23, 2004 11:07 am
Posts: 7
Location: Switzerland
Excuse me, my english is not so good, so I try to explain my problem:

I want to know how hibernate can handle the lock of records ?
If I have a user A who is currently editing a record, who can I block that record from the other user ?

Tx


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 23, 2004 11:57 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You usually don't do such a thing (since it would require long running database connections with open database locks), a much better option is optimistic concurrency control (thats what Hibernate offers, in all other aspects, it relies on the database system). Almost every documentation about transaction handling and locking should have the information about both.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 12:53 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
session.lock(...) or versioning - versioning work if You update database with hibernate only and
session.lock work always

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 3:56 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Wrong, you can use optimistic-lock="all" and compare all columns. Versioning works just fine if many applications access the same database, even without version or timestamp columns.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 7:35 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Christian,
It is fine, but what if I want that nobody touch row until I finish and I haven't changes yet

regrads


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 7:36 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You either keep the database connection open and hold a pessimistic lock in the database or you implement something like an "offline pessimistic lock" yourself. Martin Fowler has it in his patterns collection.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 10:24 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Christian,
It help me true database true."offline pessimistic lock" don't help for another application
Your versioning is great for every case except big oltp application with a lot updates

I make swing application and I want that when user type one character in form application/database lock row and another user have notification when she/he type first character.
Versioning can help and with this case:
scenario :
user A can populate row and wait;lock doesn't exist
user B change same row and commit
user A change and commit and without versioning he rewrite data form user B

Oracle tools (developer) have this problem.

I will set versioning (probably optimistic-lock="all") and pure database lock for oltp
However, versioning don't help for legacy application.
Hibernate have great locking for hibernate only, but there isn't complete correct solution for
legacy application

regards


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