-->
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: Custom sql-insert that generates the key (Oracle) ?
PostPosted: Tue Jan 04, 2011 9:48 am 
Regular
Regular

Joined: Thu Oct 19, 2006 12:07 pm
Posts: 75
Hi!

I use stored procedures for creating objects.

The current config is like this, using org.hibernate.dialect.Oracle10gDialect:
Code:
<class name="Event" table="EVENTS">
        <id name="id" column="EVENT_ID">
            <generator class="sequence"/>
        </id>
        <property name="date" type="timestamp" column="EVENT_DATE"/>
        <property name="title"/>

        <sql-insert  check="none" callable="true">{call createEventHB (?, ?, ?)}</sql-insert>
    </class>


Now when doing a session.save(newEventObject), two DB calls are made:
Code:
Hibernate:    select  hibernate_sequence.nextval from dual
Hibernate:    {call createEventHB (?, ?, ?)}


How to make only the second call and let the stored procedure to generate an ID value?
I tried to set generator class="identity", but it complains that it is not supported by the dialect.

Is there a way with Hibernate v3.6.0 to do this?

Regards,
David


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.