-->
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.  [ 2 posts ] 
Author Message
 Post subject: Generated SQL uses '?' for parameter holders?
PostPosted: Tue Jul 31, 2007 4:38 pm 
Newbie

Joined: Tue Jul 31, 2007 4:25 pm
Posts: 1
For some reason NHibernate is generating SQL and instead of using @param1, @param2 it is using ?'s (see below). We originally thought it must be a problem with the dialect but have confirmed that we are using MsSqlServer2000Dialect...

We also verified that the variables are not null, and even tried using constants instead -same result.

We also tried several other dialects (even Oracle 9) and it still generated the same SQL.

Any help or insight would be greatly appreciated.

NHibernate 1.2.1

SQL Server 2000

Generated SQL Snippet:
Code:
WHERE (this_.ActionName = ? and this_.SinkName = ?) <-- Why is it ?'s instead of @param?


Code:
Code:
ISession session = NHibernateHelper.DefaultSessionFactory.GetSession();

IList<IControllerAction> actions = session.CreateCriteria(typeof(IControllerAction))
                .Add(Expression.And(Expression.Eq("Name", name), Expression.Eq("Sink", sink)))
                .List<IControllerAction>();


Complete generated SQL:
Code:
SELECT this_.ActionId as ActionId6_2_,
            this_.Updated as Updated6_2_,
            this_.ActionName as ActionName6_2_,
            this_.SinkName as SinkName6_2_,
            this_.Layout as Layout6_2_,
            this_.ExternalUrl as External6_6_2_,
            this_.IsAuthRequired as IsAuthRe7_6_2_,
            this_.IsEnabled as IsEnabled6_2_,
            this_.Expires as Expires6_2_,
            this_.Created as Created6_2_,
            this_.CreatedBy as CreatedBy6_2_,
            this_.LastModified as LastMod12_6_2_,
            this_.LastModifiedBy as LastMod13_6_2_,
            'C' as clazz_2_,
            usermeta2_.UserId as UserId0_0_,
            usermeta2_.UserName as UserName0_0_,
            usermeta2_1_.Email as Email1_0_,
            usermeta3_.UserId as UserId0_1_,
            usermeta3_.UserName as UserName0_1_,
            usermeta3_1_.Email as Email1_1_
FROM Actions this_

left outer join    aspnet_Users usermeta2_
            on this_.CreatedBy = usermeta2_.UserId

left outer join aspnet_Membership usermeta2_1_
            on usermeta2_.UserId = usermeta2_1_.UserId

left outer join aspnet_Users usermeta3_
            on this_.LastModifiedBy = usermeta3_.UserId

left outer join    aspnet_Membership usermeta3_1_
            on usermeta3_.UserId = usermeta3_1_.UserId

WHERE (this_.ActionName = ? and this_.SinkName = ?)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 01, 2007 12:50 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
What you see is not the actual SQL that gets executed, but an intermediate representation of it.


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