-->
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: hibernate 4 and stored procedres for inserting records
PostPosted: Sat Feb 25, 2012 5:24 pm 
Newbie

Joined: Sat Feb 18, 2012 11:31 am
Posts: 5
hello all, I need help with a stored procedure for inseting records in a postgres table:
i have the mapping file whith this configuration:
<hibernate-mapping>
<class name="blom.log.model.xhostclass" table="x_hosts">
<id name="iId" column="pk_codehost" type="int" unsaved-value="-1">
<generator class="identity">
</generator>
</id>
<property name="sHost" type="java.lang.String" access="field">
<column name="d_host" />
</property>

<sql-insert callable="true" check="none">
{call insert_host(:dHost)}
</sql-insert>


</class>
</hibernate-mapping>


My problem is that i don't know how to refer that in java code, how to execute the procedure. I'm trying something like

Transaction tx = null;
tx = session.beginTransaction();

Query query = session.getNamedQuery("insert_host");
query.setString("dHost", "host1");
query.executeUpdate();

but the error is Named query not known: insert_host

Any help please???
thanks in advance.


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.