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.  [ 2 posts ] 
Author Message
 Post subject: Mapping select nextval from sequence
PostPosted: Wed Aug 15, 2007 11:05 am 
Newbie

Joined: Wed Apr 25, 2007 8:23 am
Posts: 8
Hello,

I'm trying to fetch nextval from a DB2-Sequence.
Hbernate-Mapping looks like this:

Code:
   <sql-query name="findNextIdInst">
   <return-scalar column="nextval" type="long"/>
   <![CDATA[
     values nextval for SCHEMA.ID_SEQUENCE
   ]]>
   </sql-query>



When executimng I'm getting the error message:
Code:
com.ibm.db2.jcc.b.SqlException: Invalid argument: unknown column name nextval


In Toad for DB2 it works.

What is wrong ?

Thanx,
NoLa

[/code]


Top
 Profile  
 
 Post subject: try other configuration
PostPosted: Thu Aug 16, 2007 12:37 pm 
Newbie

Joined: Wed Aug 15, 2007 3:50 pm
Posts: 6
Location: Philadelphia
our setup is different, you may want to try this instead. We have our auto-increments set up in the hibernate mapping files. When we execute an INSERT, Hibernate automatically figures out the next key and uses it:

In the classxxx.hbm.xml file, we have:
Code:
    <id name="socPatientId"
        type="long"
        column="SOC_PATIENT_ID">

         <generator class="sequence">
                <param name="sequence">SOC_PATIENT_ID_SEQ</param>
         </generator>
    </id>

When executing an insert, Hibernates generates the following SQL:

select SOC_PATIENT_ID_SEQ.nextval from dual
insert into SOC_PATIENT (..., soc_patient_id,...) values (...)

_________________
Melina Schweizer


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