-->
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: Stored Procedure Primery Key Out Parameter
PostPosted: Tue Feb 27, 2007 4:56 am 
Newbie

Joined: Tue Feb 27, 2007 4:43 am
Posts: 1
Hallo,

ist es möglich im sql-insert Bereich eine Stored Procedure zu erstellen, welche als out parameter den Primärschlüssel der eingefügten Entität zurückgibt.
Bzw.: Kann man Hibernate mitteilen, automatisch den Schlüsselwert aus einer Stored Procedure zu übernehmen.

Ich probieren jetzt schon seit Tagen, habe aber immer noch keine Lösung gefunden.

Die gespeicherte Prozedur sieht folgendermaßen aus:

PROCEDURE newProcess
(
p_retval OUT number,
p_OId IN number
)
IS
begin

p_retval := 345;

end newProcess;

Falls es nicht automatisch geht, gibt es eine Möglichkeit den zurückgegbenen Wert manual abzugreifen.





Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.infraserv.awaktree.dao.objects.node">
<class name="ProcessNode" table="ALL_PROCESSES" check="param" >
<id name="objectId" >
<column name="OID" />

</id>
<property name="dummyId" column="DUMMY2"/>

<sql-insert callable="true" >
{ call rup.newProcess (?, ? )}
</sql-insert>

</class>


</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 3:58 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Beider property kann man generated auf true setzen. Als workaround für den Primary key, kannst Du vielleicht ein select auf eine stored procedure machen, die nur den PK liefert. Beides findet man auch in der Hibernate Reference.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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.