-->
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: Problem with parameters in NamedQuery when using ENTITY def
PostPosted: Tue Jan 13, 2009 5:27 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
Hi,

I would like to define multiple Named Queries where the only difference is the order by clause. I was thinking to define a common sql-query definition without an "order by" clause and then specify the different Named Queries with the appropriate "order by" clause.

Entity Definition
Code:
<!ENTITY SQL_QUERY "select person.id, person.name from t_person where office = :officeId">


Sql-query Definitions
Code:
<sql-query name="getPersons-name-asc" <![CDATA[ %SQL_QUERY% order by person.name asc]]>
<sql-query name="getPersons-id-desc" <![CDATA[ %SQL_QUERY% order by person.id desc]]>


When using the SQL query as such, i.e. without the ENTITY definition, everything works perfectly. When running a test with the ENTITY definition, Hibernate generates the following error: "could not locate named parameter [officeId]".

What am I doing wrong ?

Regards, Stefan Lecho.

Hibernate version:
3.2.5.ga


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 13, 2009 5:51 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:54 am
Posts: 28
Using the ENTITY as shown underneath solves this issue.

Code:
<sql-query name="getPersons-name-desc">...&SQL_QUERY; order by person.name desc</sql-query>


Regards, Stefan Lecho.


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.