-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: HQL problem with composite ids...
PostPosted: Thu Feb 12, 2004 12:42 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
Hi,

Error as follows:
net.sf.hibernate.QueryException:
could not resolve property type: isValid


my .hbm.xml filehas:
<discriminator
column="isValid"
type="boolean"
/>
How do we query for a boolean in HQL...
What is wrong ?
Please help
~Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
foo.class


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
To elaborate a bit more: You can use .class to refer to the discriminator property value in your HQL. So this should works:

from Something s where s.class

Better think about using Polymorphic queries though.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:46 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
As addendum to above,

my actual query is (wondering if there is anything wrong with this:)
final String QUERY =
"from c in class " + CreditCard.class +" where c.isValid=" + true;


Thanks~


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:49 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
geoglm:
Polymorphic queries...example syntax please...
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:49 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
geoglm:
Polymorphic queries...example syntax please...
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
RTFM


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:51 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
gavin...

COuld you please elaborate...
My query currently already has .class in it
final String QUERY =
"from c in class " + CreditCard.class +" where c.isValid=" + true;

Do I need quotes around "true" above...is my syntax correct....

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Your syntax is long deprecated and I think not even correct. Read my sample I posted on how to use .class


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:55 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
Thanks again.
so i should say:
from Something s where s.class.isValid = true...
......?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 12:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
from Something s where s.class = true

.class is an alias for the discriminator value.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 2:09 pm 
Beginner
Beginner

Joined: Tue Jan 27, 2004 10:59 am
Posts: 24
Thanks again.
Not sure if I am interpreting correctly or no, but do we not need to have
class.attribute=true, instead of class=true, as in, from Something s where s.class.isalid=true...


I am currently getting this exception:
"from "
+ CreditCard.class
+ " c where c.isValid="
+ true;
for :
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
Caused by: net.sf.hibernate.QueryException: unexpected token: class [from c class com.credit.CreditCard where class com.credit.CreditCard =true]

Thanks for the reply!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 2:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, it's just like I posted, why don't you believe me? http://www.hibernate.org/hib_docs/reference/html/query-language.html#query-language-s5


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 2:15 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
from CreditCard c where c.isValid=true

Code:
from CreditCard as c where c.isValid=true


Both are valid

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2004 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Disregard my post, read too fast.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.