-->
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: SQL query as namedQuery ?
PostPosted: Tue Mar 09, 2004 12:14 pm 
Regular
Regular

Joined: Thu Aug 28, 2003 2:42 pm
Posts: 77
Location: The Netherlands
Hellu,

I am using hibernate version 2.1.1.

I have all my HQL queries documented as named queries in the mapping files through the query tag.

I now have a native SQL query as Hibernate doesn't support subqueries in the FROM.
How is the best thing to deal with this such that I document it outside my source and use it in the source ?:

I quess I have to use session.createSqlQuery(String).

But is it correct to do it like this:
String queryStr = session.getNamedQuery(namedQuery.getName()).getQueryString();
Query qry = session.createSqlQuery(queryStr);

And then add my query parameters:
qry.setParameter("some name", "some value");

Please let me know if this is the correct way to do it, some best pratice advice ?

Regards,
Ed Bras


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 12:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
http://www.hibernate.org/hib_docs/reference/html/query-sql.html#query-sql-s3


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.