-->
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.  [ 4 posts ] 
Author Message
 Post subject: pessimistic lock and setMaxResults() problem
PostPosted: Mon Mar 22, 2004 1:06 pm 
Beginner
Beginner

Joined: Tue Feb 17, 2004 11:20 am
Posts: 28
Hi,

I have one query which has been working for a while,
no I have to use pessimistic locking with this query.

I do the following,

If I remark the maxAmount part, it works
if I remark the setLockMode() part it works

but if both are used I got the following sql generated ->

select * from ( select mitgliedsc0_.mg_nr as mg_nr, mitgliedsc0_.letztesverarbeitungsdatum as letztesv2_, mitgliedsc0_.instanz as instanz, mitgliedsc0_.beginndatum as beginnda4_, mitgliedsc0_.aktion as aktion, mitgliedsc0_.bankleitzahl as bankleit6_, mitgliedsc0_.ck_hauptmitglied as ck_haupt7_, mitgliedsc0_.clubkarten_nr as clubkart8_, mitgliedsc0_.clubkarten_nr_hauptmitglied as clubkart9_, mitgliedsc0_.einschreibgebuehr as einschr10_, mitgliedsc0_.email as email, mitgliedsc0_.geburtsdatum as geburts12_, mitgliedsc0_.geschlecht as geschlecht, mitgliedsc0_.haus_nr as haus_nr, mitgliedsc0_.hausnummernzusatz as hausnum15_, mitgliedsc0_.kat as kat, mitgliedsc0_.kfz_kennzeichen as kfz_ken17_, mitgliedsc0_.konto_nr as konto_nr, mitgliedsc0_.leistungsart as leistun19_, mitgliedsc0_.lenker as lenker, mitgliedsc0_.mitarbeiter_nummer as mitarbe21_, mitgliedsc0_.mitgliedsbetrag as mitglie22_, mitgliedsc0_.name as name, mitgliedsc0_.plz as plz, mitgliedsc0_.satzart as satzart, mitgliedsc0_.schutzbriefbetrag as schutzb26_, mitgliedsc0_.staat as staat, mitgliedsc0_.strasse as strasse, mitgliedsc0_.telefon as telefon, mitgliedsc0_.text as text, mitgliedsc0_.titel as titel, mitgliedsc0_.verarbeitungsstatus as verarbe32_, mitgliedsc0_.vorname as vorname, mitgliedsc0_.wiederaufleben as wiedera34_ from mapl.MITGLIEDSCHAFT_SCHUTZBRIEF mitgliedsc0_ where (mitgliedsc0_.verarbeitungsstatus=? ) for update ) where rownum <= ?


this is the code ->

tx = session.getOriginalSession().beginTransaction();

Query q = session.getOriginalSession().createQuery(
" select mitgliedschaftschutzbrief from MitgliedschaftSchutzbrief as mitgliedschaftschutzbrief "
+ " where mitgliedschaftschutzbrief.verarbeitungsstatus = :status ");
q.setCharacter("status", status.getType());

// amount must be bigger than 0, otherwise all recrod found are
// returned
if (maxAmount > 0) {
q.setMaxResults(maxAmount);
}

// if pessimistic lock required we lock the whole select (SQL
// select ... for update)
if (pessimisticLock) {
q.setLockMode("mitgliedschaftschutzbrief", LockMode.UPGRADE);
}

result = q.list();

tx.commit();

I have no experience with this setLockMode stuff, so maybe I'm doing something wrong there...

in the doc I could not find the starting point.
as setLockMode says :
"Set the lockmode for the objects idententified by the given alias that appears in the FROM clause."

I use ORACLE as DB

Thanks for any idea.

Istvan


Top
 Profile  
 
 Post subject: Sorrry
PostPosted: Tue Mar 23, 2004 4:56 am 
Beginner
Beginner

Joined: Tue Feb 17, 2004 11:20 am
Posts: 28
Hi,

Yesterday I was so tired when I posted my question I forgot to post that I got an SQL Exception -> missing right parenthesis. It came to my mind when I woke up this morning. Sorry about that.

It seems If I use query.setLockmode, and limiting the result,
the SQL query is generated with the wrong way.

Thanks for any advices


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 23, 2004 5:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So, this is actually a bug in 2.1.2 that has already been fixed, but only in the 2.2 branch. If you submit a bug report, maybe some nice person will port the fix back to 2.1 for you, or, even better, look at the change to Loader (calling Dialect.getLimitString() /before/ calling Loader.applyLocks() and backport this change yourself.


Top
 Profile  
 
 Post subject: thanks
PostPosted: Tue Mar 23, 2004 5:09 am 
Beginner
Beginner

Joined: Tue Feb 17, 2004 11:20 am
Posts: 28
Thanks a lot for the quck response, I thought it's my being lame as I'm really new to hibernate. I will take a look what I can do.

Istvano


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