-->
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: Problem using scalar queries on sequence
PostPosted: Mon Jan 17, 2005 9:56 pm 
Newbie

Joined: Fri Jan 07, 2005 3:34 pm
Posts: 8
List list = so.session.find("select FIELD_ID_SEQUENCE.nextval from dual");

results in this exception:
net.sf.hibernate.QueryException: undefined alias: FIELD_ID_SEQUENCE [select FIELD_ID_SEQUENCE.nextval from dual]

I know for sure my sequence is in the DB. Also, I have no trouble with using sequences with <generator> in my mappings file.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:10 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
find takes HQL not SQL

_________________
Emmanuel


Top
 Profile  
 
 Post subject: How do I natively use an oracle sequence then?
PostPosted: Thu Jan 20, 2005 4:16 pm 
Newbie

Joined: Fri Jan 07, 2005 3:34 pm
Posts: 8
I tried using CreateSQLQuery which is for native queries, but I can't get it to work with an oracle sequence. Is it possible use oracle sequences without using the <generator> ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 20, 2005 4:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You cannot map general properties using a sequence.

session.createSQLQuery() is used for "native sql queries", for which "select FIELD_ID_SEQUENCE.nextval from dual" is not valid (read the docs as to why).

If you want to get the value of a sequence for something other than an <id/>, just get a handle to the session's connection and do it:
Code:
session.connection().prepareStatement("select FIELD_ID_SEQUENCE.nextval from dual")...


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.