-->
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: [Criteria Query API] Get objects with specified class
PostPosted: Sun Nov 07, 2010 7:22 am 
Newbie

Joined: Sun Oct 17, 2010 7:54 am
Posts: 5
Hi, All.
I can get object with specified class in HQL like this:
Code:
from Animal as a where a.class = Cat


How can i do this in Criteria Query?

This code is finished with error "java.lang.IllegalArgumentException: Illegal attempt to dereference path source [null]":
Code:
Root<Animal> root = criteria.from(Animal.class);
criteria.where( builder.equal( root.get("class"), "Cat" ) );


And also this code is finished with same error:
Code:
Root<Animal> root = criteria.from(Animal.class);
criteria.where( builder.equal( root.get("class"), Cat.class ) );


Top
 Profile  
 
 Post subject: Re: [Criteria Query API] Get objects with specified class
PostPosted: Mon Nov 08, 2010 7:38 pm 
Beginner
Beginner

Joined: Tue Oct 26, 2010 6:12 pm
Posts: 29
Try:

Code:
criteria.where(root.type().in(Cat.class));


Even that might not work due to:
http://opensource.atlassian.com/project ... e/HHH-4881


Top
 Profile  
 
 Post subject: Re: [Criteria Query API] Get objects with specified class
PostPosted: Tue Nov 16, 2010 4:29 am 
Newbie

Joined: Sun Oct 17, 2010 7:54 am
Posts: 5
Thank you for your replay (Sorry, but I could read your post just only today).

I try this code but I get the same error as error on bugzilla "Unexpected call on EntityTypeExpression#render".


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.