-->
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.  [ 1 post ] 
Author Message
 Post subject: Remove child bean results from search by criteria query
PostPosted: Wed Nov 07, 2012 9:36 am 
Newbie

Joined: Wed Nov 07, 2012 9:27 am
Posts: 1
Hello guys. Could someone please help me with my issue.
I am using hibernate 3.6. Here is what I need help with.
I have two classes FooParent and FooChild. As it stands from names FooChild extending FooParent.
When I am trying to find by criteria all FooParent classes it returns me FooChildes in list too.
I am searching like this.
Code:
DetachedCriteria criteria = DetachedCriteria.forClass(FooParent.class);

Adding some restrictions:
Code:
criteria.add(Restrictions.ilike(...));

Then calling for result list:
Code:
List result = getHibernateTemplate().findByCriteria(criteria);
.

The result list contains FooChildes also if they are matching the criteria. I want them to be removed from searching and result list subsequently. What need to be done to search criteria? I google my problem but only thing I've found is add restriction:
Code:
criteria.add(Restrictions.eq("class", FooParent));

Which is not working due to "there is no property 'class' of the bean FooParent" exception.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.