-->
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: sql-insert
PostPosted: Wed Feb 01, 2006 11:30 am 
Newbie

Joined: Fri Jan 27, 2006 8:04 am
Posts: 8
I've got a case similar to the code in the hibernate3 documentation:

Code:
   <class name="com.spod.LookupValue" table="dummy">
      <id name="id" column="dummy1"/>
      <property name="text" column="dummy2"/>
      <property name="sourceType" column="dummy3"/>   
       <loader query-ref="load-lookup"/>
       <sql-insert callable="true">{? = call insertFunc3(?, ?, ?)}</sql-insert>
   </class>


Now, I get an error that not all variables are bound. Wait! Read further.

My SP is:

Code:
CREATE OR REPLACE function insertFunc3(textParam in varchar2(20), sourceParam in varchar2(20), newId out integer)
return integer


I understand that the return value counts as a variable, and so I only supply 3 variables, where 4 are required.

But how do I call this function? Ideally I only want to supply the two properties, and have the generated key returned to me as the return value from the SP.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 01, 2006 8:27 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The answers are all in section 16.4, "Custom SQL for create, update and delete", of the ref docs. Your sql-insert statement does not follow the mandatory, cannot-be-changed-at-all format required by hibernate. sql-insert will not handle a return value. The parameters are passed in in exactly the order that hibernate specifies: that ref doc section tells you how to find out the order.

So you need
Code:
<sql-insert callable="true">{call insertFunc3(?, ?, ?)}</sql-insert>
The first parameter will always be an in/out parameter for the id; the other two will probably be in test, sourceType order, but you should enable debug logging for the org.hibernate.persister.entity level to verify.


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.