-->
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: Manually using Oracle sequences
PostPosted: Fri Jul 28, 2006 10:56 am 
Newbie

Joined: Fri Jul 28, 2006 10:53 am
Posts: 15
How do I get the next value in an Oracle sequence in Hibernate? The corresponding SQL code is "select audit_control.nextval from dual".


Top
 Profile  
 
 Post subject: sequence value
PostPosted: Fri Jul 28, 2006 5:27 pm 
Newbie

Joined: Fri Oct 14, 2005 4:42 pm
Posts: 15
You could do it this way:

Code:
Integer nv = (Integer)hbSession.createSQLQuery("select audit_control.nextval from dual").uniqueResult();


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 29, 2006 2:36 pm 
Newbie

Joined: Fri Jul 28, 2006 10:53 am
Posts: 15
I tried that, but Hibernate complained about being unable to map "dual"?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 30, 2006 1:33 am 
Newbie

Joined: Sat Jul 29, 2006 3:36 pm
Posts: 1
Try this -

Integer nv = (Integer)hbSession.createSQLQuery("select audit_control.nextval as ID from dual").addScalar("ID", Hibernate.INTEGER).uniqueResult();

_________________
Thanks,
Kamal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 11:49 am 
Newbie

Joined: Fri Jul 28, 2006 10:53 am
Posts: 15
Unfortunately that didn't work either: "org.hibernate.exception.DataException: could not execute query"

I decided to add a sequence generator to a table mapping instead and that works fine, so finding an answer to this problem isn't very important any more now; I appreciate people trying to help though! It mystifies me why manually generating a sequence value isn't documented and thus at the moment is impossible to do :/


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.