-->
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: Named parameters with Hibernate and Stored Procedures
PostPosted: Mon Feb 06, 2012 2:14 pm 
Newbie

Joined: Fri Oct 28, 2011 12:55 pm
Posts: 3
Hi All,

I am trying to call stored procedures with hibernate to perform inserts, and got it to work partially, where each property in the mapping class is passed as a parameter to stored procedure in the order of mappings.

For example:

Code:
<class name="EventEntity" table="APP_EVENT">
        <id name="id" column="APP_EVENT_ID">
            <generator class="assigned" />
        </id>
        <property name="title" column="PAYLOAD_BIZ_EVENT_TITLE" />
        <property name="userId" column="USER_ID"/>
        <property name="application" column="APPLICATION_ID"/>
<!—
The order of input parameters in this case would be tittle, userId, application and finally the id.
-->
        <sql-insert callable="true">{call insertEvent(?,?,?,?)}</sql-insert>
</class>


Is there a way to specify input parameters to stored procedure as named parameters, and not worry about the order of mappings in hibernate files?

I tried to replace the sql-insert with

Code:
<sql-insert callable="true">{call insertEvent(@USER_ID=?,@APPLICATION_ID=?,@APP_EVENT_TYPE_ID=?,@APP_EVENT_ID=?,@PAYLOAD_BIZ_EVENT_TITLE=?)}</sql-insert>


but it did still adhered to the order of the property mappings.

Regards,
Malay


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.