-->
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.  [ 2 posts ] 
Author Message
 Post subject: Excluding an objects collections/entities in a search
PostPosted: Wed Jul 01, 2009 1:02 am 
Newbie

Joined: Mon Sep 25, 2006 2:18 am
Posts: 3
Hi

What is the best/easiest way to exclude certain collections belonging to an object ?

Let's say that we have object A, A contains an entity B (@OneToOne, @JoinColumn..) and a collection C (@OneToMany..@JoinColumn) and another collection D. B has a collection of BE's (@OneToMany..).

I now want to fetch an A depending on a criteria but only load the A and it's entity B + BE's. Or perhaps the A and it's collection D.

Is there a simple way to exclude certain objects/relations when doing a search ?

/Laban


Top
 Profile  
 
 Post subject: Re: Excluding an objects collections/entities in a search
PostPosted: Sun Oct 18, 2009 7:23 am 
Newbie

Joined: Tue Aug 26, 2008 12:18 pm
Posts: 9
Hi,

There isn't any 'excluding' of collections/entities. By default hibernate will fetch only the entity, you asked for.

Hibernate can fetch associated entities either 'Lazily' (the collection is fetch, when it is used) or 'Eagerly (the collection is fetched in the time of fetching the 'parent' entity. The fetching strategy can be set either in the mapping file ( fetch = "select" for lazy fetching, and fetch = "join" for egager fetching), or it can be set while creating the query or criteria (criteria.setFetchMode("propertyName", FetchMode.JOIN/FetchMode.SELECT) )

Hope it helps.

_________________
Arguing on the Internet is like running in the Special Olympics.

Even if you win, you’re still retarded. :P


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