-->
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.  [ 1 post ] 
Author Message
 Post subject: StoredProc with "sequence-identity" generator ( sq
PostPosted: Tue May 06, 2008 8:58 pm 
Newbie

Joined: Tue May 06, 2008 8:40 pm
Posts: 1
I want to override Hibernate's default insert statement by calling an Oracle stored procedure, and at the same time use the "sequence-identity" generator for the ID.

Here's a snippet of my Mapping file...
Code:
<class name="com.test.orm.Process" table="PROCESS">
  <id name="processId" type="java.lang.Integer">
    <column name="PROCESS_ID" precision="22" scale="0"/>
      <generator class="sequence-identity">
        <param name="sequence">PROCESS_SEQ</param>
      </generator>
  </id>
 
  <property name="creationDate" type="timestamp" generated="insert">
    <column name="CREATION_DATE" length="11" not-null="true"/>
  </property>
 
  .... (other properties)
 
  <sql-insert callable="true" check="none">{call create_process (?, ?, ?, ?, ?, ?)}</sql-insert>
 
</class>


Currently (with generator class set to 'sequence') hibernate issues 3 calls.
- 1 call to get Sequence.nextval
- 1 call to insert record
- 1 call to get the CreationDate after record inserted

I got rid of 1 of the calls by using "sequence-identity" generator which uses the JDBC driver and calls getGeneratedKeys() -- now I am trying to get rid of the call to get creationDate (I need the date generated by the DB).


So does anyone know how to use Custom SQL for CRUD with stored procedures and sequence-identity generator?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.