-->
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.  [ 3 posts ] 
Author Message
 Post subject: Hibernate Exception:Named parameter does not appear in Query
PostPosted: Wed Jul 15, 2009 3:44 pm 
Newbie

Joined: Wed Jul 15, 2009 3:35 pm
Posts: 2
Need Help!!

I get the following hibernate error in my java code:

net.sf.hibernate.QueryException:Named parameter does not appear in Query: status [from hci.csadmin.model.Asset as ass WHERE ass.status IS NOT NULL AND ass.status IN ('Checked','UnChecked') ]

All I did was change the query from:

if (assetSearchForm.getStatus()!= null && !assetSearchForm.getStatus().equals("All"))
{

querySb.append(" AND ass.status = :status");
isStatus = true;
}

to what is given below. This was done to incorporate a case to fetch all the rows where status is checked or unchecked.

if (assetSearchForm.getStatus()!= null && !assetSearchForm.getStatus().equals("All"))
{
if (assetSearchForm.getStatus().equals("Checked & Unchecked"))
{
querySb.append (" AND ass.status IN (\'Checked\',\'UnChecked\') ");
isStatus = true;
}
else
{
querySb.append(" AND ass.status = :status");
isStatus = true;
}
}


The code works fine if I choose the status as Checked or as unchecked. That is when it goes in the else block it forms the query right and works fine but when it is in the If block it gives me the error.

I have tried to google the error message for some pointers with no success. Also I tried replacing IN clause with ass.status='Checked' OR ass.status='Unchecked' but still the same error.

Any help will be greatly appreciated.

Ruby.


Top
 Profile  
 
 Post subject: Re: Hibernate Exception:Named parameter does not appear in Query
PostPosted: Wed Jul 15, 2009 10:11 pm 
Newbie

Joined: Wed Jul 15, 2009 1:55 am
Posts: 1
Location: china beijing
from hci.csadmin.model.Asset as ass WHERE ass.status IS NOT NULL AND ass.status IN ('Checked','UnChecked')

it like a sql but not a hql.
but,it is from entity ,not table
I don't understand the query code




good luck


Top
 Profile  
 
 Post subject: Re: Hibernate Exception:Named parameter does not appear in Query
PostPosted: Thu Jul 16, 2009 11:27 am 
Newbie

Joined: Wed Jul 15, 2009 3:35 pm
Posts: 2
I am too not fond at hql.

Its a query forming on the fly depending on the input parameters.

One thing thats worth a shot is using parameterized list for Checked,Unchecked. Let me give this a shot and see how it goes.

Ruby.


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