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.  [ 6 posts ] 
Author Message
 Post subject: Query firing multiple selects
PostPosted: Thu Jan 31, 2008 4:05 pm 
Newbie

Joined: Sat Jun 09, 2007 8:22 pm
Posts: 9
I have this query:
Code:
IQuery query = session.CreateQuery("from BlogEntity b where b.Host = :host and b.Path = :path");
query.SetParameter("host", host);
query.SetParameter("path", path);

return query.UniqueResult<BlogEntity>();


That works fine, just as intended, but the SQL log show 2 select statements as does SQL Profilier.
Code:
NHibernate: select blogentity0_.Id as Id0_, blogentity0_.Name as Name0_, blogentity0_.Host as Host0_, blogentity0_.Path as Path0_, blogentity0_.Skin as Skin0_ from Blog blogentity0_ where (blogentity0_.Host=@p0 )and(blogentity0_.Path=@p1 ); @p0 = 'LocalHost', @p1 = 'Path1'
NHibernate: select blogentity0_.Id as Id0_, blogentity0_.Name as Name0_, blogentity0_.Host as Host0_, blogentity0_.Path as Path0_, blogentity0_.Skin as Skin0_ from Blog blogentity0_ where (blogentity0_.Host=@p0 )and(blogentity0_.Path=@p1 ); @p0 = 'LocalHost', @p1 = 'Path1'


Why are two selects being executed?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 01, 2008 5:25 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
those selects are identical
maybe there's a bug on the outputing


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 03, 2008 12:46 pm 
Newbie

Joined: Sat Jun 09, 2007 8:22 pm
Posts: 9
I thought it may be the logging as well, but when I use SQL Profiler that shows all the SQL getting executed on the DB, it shows 2 statements, that are identical, being executed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 22, 2008 10:05 am 
Newbie

Joined: Sat Jun 09, 2007 8:22 pm
Posts: 9
Anybody have any idea on this?

I am just trying to understand what is going on.

I look at SQL Profiler( shows the SQL being executed on the DB) and this query shows up twice:

exec sp_executesql N'select blogentity0_.Id as Id0_, blogentity0_.Name as Name0_, blogentity0_.Host as Host0_, blogentity0_.Path as Path0_, blogentity0_.Skin as Skin0_ from Blog blogentity0_ where (blogentity0_.Host=@p0 )and(blogentity0_.Path=@p1 )',N'@p0 nvarchar(9),@p1 nvarchar(5)',@p0=N'LocalHost',@p1=N'Path1'


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 22, 2008 1:52 pm 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
post the mapping... maybe that will give a clue


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 24, 2008 11:40 am 
Newbie

Joined: Sat Jun 09, 2007 8:22 pm
Posts: 9
Here is the mapping file, its pretty standard as far as I know.

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="YABE.Core" namespace="YABE.Core.Domain">
<class name="BlogEntity" table="Blog">
<id name="Id" column="Id" access="field.camelcase">
<generator class="identity" />
</id>
<property name="Name" />
<property name="Host" />
<property name="Path" />
<property name="Skin" />
</class>
</hibernate-mapping>

Here is the configuration: (I am using Castle's NHibernate facility, which is why the config looks a bit different)

<item key="hibernate.connection.provider">NHibernate.Connection.DriverConnectionProvider</item>
<item key="hibernate.connection.driver_class">NHibernate.Driver.SqlClientDriver</item>
<item key="hibernate.connection.connection_string">Data Source=(local)\SQL2005;Initial Catalog=YABE_Test;Integrated Security=SSPI</item>
<item key="hibernate.dialect">NHibernate.Dialect.MsSql2005Dialect</item>
<item key="hibernate.show_sql">true</item>


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