-->
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: isolation-level "RR" on AS400/DB2 - HQL or Dialect
PostPosted: Mon Jan 24, 2005 12:23 pm 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
Hibernate version: 2.1.7
Hi there,

i hope someone can and want answer me ...

In same situations i need to do a 'select' with isolation-level repeatable read. Not always ... only sometimes.
On a AS400/DB2 you can do that by adding a 'with RR' to the select-clause.

I've tried this via HQL and a named query, but got :
Code:
Exception in thread "main" net.sf.hibernate.QueryException: unexpected token: RR [from com.test.hibernate.hql.data.TestWithRR with RR]
   at net.sf.hibernate.hql.FromParser.token(FromParser.java:101)
   at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
   at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:142)
   at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
   at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295)
   at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1571)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1542)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
   at com.test.hibernate.hql.WithRRTest.runTest(WithRRTest.java:42)
   at com.iks.hibernate.hql.WithRRTest.main(WithRRTest.java:34)


My question is if it's possible at all doing it, if the sql-parser don't know it.
Or can i do it by patching the AS400Dialect? But in which method i must do that? I think it's something like the "for update" ... But i've only found a method to decide whether "for update" is possible... but not how it looks like ...

thx!
curio


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 24, 2005 9:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Cannot do it with HQL. Use a SQL query, eg, sess.createSQLQuery().
See

http://www.hibernate.org/hib_docs/reference/en/html/querysql.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 25, 2005 4:15 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
hi david,

thanks for your answer!!
I hoped that it's possible to do this in a not db-specific way using a Dialect ... but sure, hibernate couldn't handle all formats of each exisiting database ... i think that would be a little bit to much ;)

I'll do that with a sql-query ... so thanks for your hint!

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 25, 2005 9:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Actually you can use
query.setLockMode("alias", LockMode.UPGRADE);
it will do a "for update with rr" in DB2
Not sure it fits your needs however

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 26, 2005 6:22 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
i've looked in the iseries/udb documentation and found that 'for update with rr' is working .. and tried it ... the pure select is working perfectly ... 'for update' is not really necessary, but i think it can't hurt ;)

so thanks a lot! I will try it with "query.setLockMode" ...

gtx
curio


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.