-->
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.  [ 5 posts ] 
Author Message
 Post subject: NHibernate stored procedure bug?
PostPosted: Mon Apr 23, 2007 4:21 pm 
Newbie

Joined: Mon Apr 23, 2007 3:55 pm
Posts: 10
Description:
It works fine with just one procedure parameter, but when I add one or more i gives me this error. Anyone that have any clue to why?! All I can think of is that NHibernate generates the parameters wrong? And no, it does no matter if if write the parameters with () eg. (:Username :Password).

Hibernate version:
1.2.0.CR2

Mapping documents:
<sql-query name="RegisterSid">
<return-scalar column="Result" type="Int32" />
exec spRegisterSid :Username :Password
</sql-query>

Full stack trace of any exception that occurs:
NHibernateTest.Tests.Data.UserDaoTest.CreateUser : NHibernate.ADOException : could not execute query
[ exec spRegisterSid ? ? ]
Name: Username - Value: Foo
Name: Password - Value: qwerty123
[SQL: exec spRegisterSid ? ?]
----> System.Data.SqlClient.SqlException : Line 1: Incorrect syntax near '@p1'.

at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
at NHibernate.Impl.SessionImpl.ListCustomQuery(ICustomQuery customQuery, QueryParameters queryParameters, IList results)
at NHibernate.Impl.SessionImpl.List[T](NativeSQLQuerySpecification spec, QueryParameters queryParameters)
at NHibernate.Impl.SqlQueryImpl.List[T]()
at NHibernateTest.Data.UserDao.Create(String username, String password) in E:\.www\NHibernateTest\NHibernateTest\Data\UserDao.cs:line 42
at NHibernateTest.Tests.Data.UserDaoTest.CreateUser() in E:\.www\NHibernateTest\NHibernateTest.Tests\Data\UserDaoTest.cs:line 36
--SqlException
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)


Name and version of the database you are using:
SQL Server 2000 SP3


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 10:14 pm 
Regular
Regular

Joined: Mon Mar 20, 2006 10:49 pm
Posts: 59
Try separating the parameters with a comma.

_________________
Mike Abraham


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 2:17 am 
Newbie

Joined: Mon Apr 23, 2007 3:55 pm
Posts: 10
Oh my god... Sorry for this lame post.


Top
 Profile  
 
 Post subject: :-/
PostPosted: Fri May 04, 2007 11:17 am 
Newbie

Joined: Fri May 04, 2007 11:13 am
Posts: 1
Actually thanks for the lame post, I did the same thing :-/


Top
 Profile  
 
 Post subject: Re: NHibernate stored procedure bug?
PostPosted: Tue May 22, 2007 9:25 am 
Newbie

Joined: Tue May 22, 2007 9:19 am
Posts: 4
Hi i need to excute a store procedure, but i dont understand to do.
¿Where write this code? in wich class??
Mapping documents:
<sql-query name="RegisterSid">
<return-scalar column="Result" type="Int32" />
exec spRegisterSid :Username :Password
</sql-query>

Name and version of the database you are using:
SQL Server 2000 SP3[/quote]

please help!


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