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.  [ 5 posts ] 
Author Message
 Post subject: Pessimistic row-level locking
PostPosted: Mon Aug 15, 2005 11:26 am 
Newbie

Joined: Tue May 03, 2005 3:18 pm
Posts: 9
Hibernate version:
Hibernate 3.0.5

I'm trying to accomplish database row-level locking for a table using a Hibernate entity
similar to what could be done with an entity bean. Is this possible?

I read in the documentation about getting an upgrade lock, and this
is certainly seems feasible, but that leaves two questions:

1) Can this be specified declaratively in the mapping file if all
access to this entity should be pessimistic?

2) Will concurrent attempts to access a given row wait for access
to that row, or immediately return either throwing an exception,
or returning null?

btw, I'm using Hibernate with a clustered JBoss 4.0.2 AS. I'm also
using a Statelesss Session Bean facade for entity access.

Thanks for any help that anyone can give.....

Raj


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Eh? You want to *always* use a pessimistic lock when querying a particular class?!

Is this 'cos you have a requirement that your system should be as slow and unscalable as possible?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 3:43 pm 
Newbie

Joined: Tue May 03, 2005 3:18 pm
Posts: 9
point well taken.

OK, let me back up....

Due to certain user requirements, I need to generate IDs (for the user's benefit).
The problem is that it's not as simple as that sounds, because they need IDs
of the form TOKEN1_TOKEN2_ID# where TOKEN1 and TOKEN2 are dynamically
chosen based on the user, and the ID# is an incremented integer per user event.
For example, it could be John_Doe_1 or Gavin_King_42. The key point is that the
next event from Gavin King would generate Gavin_King_43 (and there is no way
that this information could be stored at the user level)

This could almost be an Oracle sequence or SQLServer identity, but not quite (I think).
Compound this with the fact that we are either picking SQLServer or Oracle, but
which is not known at this time, and we may even have multiple deployments,
each using a different database vendor.

I am completely open to alternatives if you (or anyone else) has one.
Thanks for any help that anyone can give.

Raj


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 3:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
implement a custom IdentifierGenerator.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 27, 2005 7:28 pm 
Newbie

Joined: Tue May 03, 2005 3:18 pm
Posts: 9
Sorry, it's been a while, but I got sidetracked with another task.

But after reviewing the currently implemented identifier generators for
an idea of how to proceed, I noticed that some of the implementations
(i.e. TableHiLoGenerator) say not to use with JTA due to the need for a
seperate transaction so that the new hi value will be committed even if
the containing transaction is rolled back. As I had stated previously, I
intend to use this within a clustered JBoss AS, in the context of a
Stateless Session Bean (with CMT if at all possible).

So, if it is still possible to use a custom IdentifierGenerator, could you
please point me to some sample code that would work in this context
and/or documentation/tutorials. This certainly seems like it could be an
elegant solution to my problem. Thanks for your help.

Raj


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