-->
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: Store Procedure + SQLServer 2000
PostPosted: Mon Feb 28, 2005 10:48 am 
Beginner
Beginner

Joined: Thu Feb 05, 2004 9:09 am
Posts: 27
Hibernate 3

Hello!
I create a store procedure in SQLServer 2000 call SPINSERT and do the mapping, see:

<sql-insert callable="true">{spinsert ?, ?}</sql-insert>
or
<sql-insert callable="true">{exec spinsert ?, ?}</sql-insert>
or
<sql-insert callable="true">{spinsert (?, ?)}</sql-insert>
or
<sql-insert callable="true">{exec spinsert (?, ?)}</sql-insert>

all the ways it occurs this exception:

Hibernate: {exec spinsert ?, ?}
WARN JDBCExceptionReporter:57 - SQL Error: 0, SQLState: 22019
ERROR JDBCExceptionReporter:58 - Unrecognized SQL escape 'exec' at line position 10.

Obs: To exeute a store procedure on SQLServer I use command "exec" ou "execute", so canĀ“t I use command "call".

If somebody help...
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well - we just execute the query as any other callable statement.

dont know how exec/spinsert differs from callable ?

.max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 2:59 pm 
Beginner
Beginner

Joined: Thu Feb 05, 2004 9:09 am
Posts: 27
See my program:

Store Procedure in SQLServer

CREATE PROCEDURE spinsert
@nomPartido varchar(50),
@sglPartido char(10),
@return int output
AS
insert into partido (nomPartido, sglPartido) values (@nomPartido,@sglPartido)
set @return = @@identity
return @return
GO

Mapping:

hibernate-mapping>
<class name="br.com.camara.camadanegocio.negocio.to.PartidoTO" table="partido">
<id name="codigo" column="idePartido" type="integer">
<generator class="native" />
</id>
<property name="nomePartido" column="nomPartido" type="string"/>
<property name="sigla" column="sglPartido" type="string"/>

<sql-insert callable="true">{call spinsert ?, ?, 0}</sql-insert>
</class>
</hibernate-mapping>

Now i try run with "call" and happend this exception:

Hibernate: {call spinsert ?, ?, 0}
ERROR PersistenciaManager:128 - Durante SAVE
org.hibernate.HibernateException: The database returned no natively generated identity value

Thank for your help


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 28, 2005 5:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - please read the stacktrace!

"The database returned no natively generated identity value"

so you have mapped you pojos to have ids using the native generator.
So, the stored procedure needs to return to hibernate which id it assigned to the object.

_________________
Max
Don't forget to rate


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.