-->
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.  [ 4 posts ] 
Author Message
 Post subject: calling a Insert Stored Procedure via "getNamedQuery&qu
PostPosted: Tue Jun 06, 2006 7:37 am 
Newbie

Joined: Mon May 29, 2006 5:23 am
Posts: 7
Hello,

I want to use a stored procedure to insert some data into my database (SQLserver 2000), but somehow it does not work. I am using the "getNamedQuery" function to call the stored procedure, and i pass parameters with it.

The code is as follows:

===
session.beginTransaction();
session.getNamedQuery("pr_tbl_test_String_INS_SP").setParameter("Oms", "blablabla");
session.getTransaction().commit;
===

This code gives no exceptions, but it does not store anything into the database. If i modify my code by building a list, i got a nullpointer exception on that list:

===
List list = session.getNamedQuery("PR_tbl_test_String_INS_SP").setParameter("Oms", "blablabla").list();
===

The procedure is a folows:

========
CREATE PROCEDURE dbo.[pr_tbl_test_String_INS_ret]
@Oms varchar(200)
AS

SET NOCOUNT ON

INSERT INTO [tbl_test_String] ([Oms])
VALUES (@Oms)

RETURN SCOPE_IDENTITY()

GO
========

In my object-mapping file i placed the following code for calling the procedure:

====
<sql-query name="pr_tbl_test_String_INS_SP"callable="true">
<return alias="bigFieldExample" class="hibernatetest.BigFieldExample">
<return-property name="id" column="id"/>
</return>
</sql-query>
====


Could anyone help me with this? Does someone have a working example for inserting data via a stored procedure, called via a "getNamedQuery" function??

Regards,
Martijn van Hagen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 2:49 pm 
Newbie

Joined: Tue Jun 06, 2006 2:24 pm
Posts: 1
I too am seeing this issue. However I have noticed that I am able to insert a record into a temp table but never into an actual concrete table. I have turned on ddl tran (sybase). The proc works as expected when executed outside of the Hibernate connection (through straight JDBC or through a SQL Editor).


Top
 Profile  
 
 Post subject: Re: calling a Insert Stored Procedure via "getNamedQuer
PostPosted: Tue Jun 06, 2006 2:53 pm 
Beginner
Beginner

Joined: Sat Jun 03, 2006 6:23 pm
Posts: 28
MartijnH wrote:
Hello,
====
<sql-query name="pr_tbl_test_String_INS_SP"callable="true">
<return alias="bigFieldExample" class="hibernatetest.BigFieldExample">
<return-property name="id" column="id"/>
</return>
</sql-query>
====


Aren't you supposed to actually specify which database funcion to call? I see you named you query similar to the procedure in the database, but I don't think that's enough.

<sql-query name="pr_tbl_test_String_INS_SP"callable="true">
<return alias="bigFieldExample" class="hibernatetest.BigFieldExample">
<return-property name="id" column="id"/>
</return>
{ ? = call pr_tbl_test_String_INS_ret( ? ) }
</sql-query>

And you could maybe enable query logging, and check that the query syntax is ok.

Roland


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 06, 2006 4:01 pm 
Newbie

Joined: Mon May 29, 2006 5:23 am
Posts: 7
Of course... i was forgotten to mention that. The call of the function is indeed in my <sql-query> tag. like you typed.

Good idea to check the syntax, i will put my mylogging on debug-mode...

In the meantime...any suggestion to help me out is more than welcome!

Regards,
Martijn


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.