-->
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: Problems with SQL generated from CreateQuery method
PostPosted: Tue Jan 17, 2006 3:01 pm 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
Hi.

I'm using the following SQL with the CreateQuery method:

Code:
string query = "FROM Atividade ORDER BY AtiId";


Well, the NHibernate generates the SQL using AtiId instead of ATI_ID (the name of the field into the database). The XML mapping is correct.

To resolve this, I used it:

Code:
string query = "FROM Atividade AS atividade ORDER BY atividade.AtiId";


Is it correct?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 3:16 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes. In HQL you can't just refer to properties without specifying which object they belong to.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 3:27 pm 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
sergey wrote:
Yes. In HQL you can't just refer to properties without specifying which object they belong to.


Hi!

And without the object, the query will be generated with tha same name of the "property"?

For example, the query above would be:

Code:
SELECT * FROM atividade ORDER BY AtiId


Is it true?

I have another question... do you know how can I do to see what SQL NHibernate generates?

Thanks Sergey!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 17, 2006 5:50 pm 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi,

As Sergey mentioned "you can't just refer to properties without specifying which object they belong to" - in the book "Hibernate in action" it is explained very nice - to treat "alias" in HQL as something like "object reference" (BTW - I just read the book almost at one sitting and I _really_ recommend doing so , it is just amazing, java instead of .net is not an issue at all here)

About watching the SQL generated - 1) use log4net -> http://www.hibernate.org/364.html , 2) for MS sql you can try sql profiler 3) there is NH configuration parameter "show_sql=true" but personally I never tried this

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 18, 2006 11:37 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
michal wrote:
About watching the SQL generated - 1) use log4net -> http://www.hibernate.org/364.html , 2) for MS sql you can try sql profiler 3) there is NH configuration parameter "show_sql=true" but personally I never tried this


And NHibernate Query Analyzer, do you know?

Thanks! :~)


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.