-->
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: how to display hibernate query string?
PostPosted: Fri Mar 18, 2005 10:58 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 11:07 am
Posts: 30
I have been getting my named parameter query work, but always failed.

In my Role.hbm.xml:

<query name="examples.getRolesFromIds">
<![CDATA[
from Role as r where r.id in :ids
]]>
</query>

I am using MS SQL server. I passed ('1', '3'), but the system complains
about syntax being error. What is the correct way to do named and
parameterized query for the above query.

As a general question, we know that hibernate issues SQL queries to database.
What configuration should I do in order for hibernate to display the sql qeuries it generates?

Thanks, Pete


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 19, 2005 12:08 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There are two way to pass the parameters. Firstly, by index. Secondly, by name. Your using a named parameter with a name of 'ids'. So query.setInt('ids', 3); Might do the trick.

Anyway, this is documented see:
http://www.hibernate.org/hib_docs/reference/en/html/manipulatingdata.html#manipulatingdata-querying

The property is showSQL="true" which is also documented.


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.