-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to do this query?
PostPosted: Fri Apr 20, 2007 5:17 pm 
Newbie

Joined: Mon Apr 02, 2007 5:09 pm
Posts: 5
Hi there...

In the documentation there is a Weblog example (Chapter 18).

I am trying to find out how to retrieve:

- a Blog object with Id 1

AND

- In the property "Items" (IList) of this blog, I would like to retrieve only the items with Title like '%abc'.

In other words, I would like to filter the Items list by some criteria, in this blog object that I am retrieving.

Is that possible? How would I do that using an ICriteria query?

I appreciate any help!
Kind regards.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 9:23 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
I think this should do the job

List blogs = sess.createCriteria(Blog.class)
.add( Restrictions.eq("id", new Integer(1)) )
.createCriteria("items")
.add( Restrictions.like("text", %abc") )
.list();


Go through this link for more info

http://www.hibernate.org/hib_docs/v3/re ... teria.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 9:26 am 
Regular
Regular

Joined: Mon Jan 22, 2007 10:32 am
Posts: 101
After going through your post again, I realize that you want to put restriction on items in Blog object.

I think this can be achieved through hibernate filters. See this for more details

http://www.hibernate.org/hib_docs/v3/re ... lters.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 23, 2007 9:40 am 
Newbie

Joined: Mon Apr 02, 2007 5:09 pm
Posts: 5
Cheers, I'll try that.


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