-->
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: Fetch join strategy
PostPosted: Mon Jul 07, 2008 8:20 am 
Newbie

Joined: Mon Jul 07, 2008 7:51 am
Posts: 1
Hi,

I'm trying to define the fetch strategy for lazy associations using JPA/Hibernate 3.2.6. It seems the @Fetch annotation is only valid for eager associations. Well, at least, I couldn't make it work otherwise. Please, prove me wrong. :-)

The main reason I'm trying this is because:

(1) I don't want a model-driven way to define which association is lazy and which isn't.
Mainly because there are various ways of using the entity model; each with their
own requirements about which association is needed and which isn't. If I put it all
eager, I'm pulling the whole database in.

(2) The resulting graph is serialized and sent to a different machine. This machine does
not has the possibility to pull lazily the associated objects. As such, the required
objects should already been pre-loaded.

I though I could have all associations set lazy and pull them in with a FETCH JOIN to overrule the lazy setting. This way the developer defines which associations should be filled-in for his particular usage.

This works *but* it doesn't use separate queries to load the associated objects. It all comes with one big query full of outer joins. which should be made distinct to eliminate duplicated values. Some objects have quite some optional associations, so this becomes quite painful for the database.

Of course it would work to have the developers run the main query without joins and let them fill in the associations lazily by calling the related accessor methods. But I was hoping to keep it simple by just defining one JPQL query with the required associations.

Any idea how I can pull it off with just one query and some configuration ?

Many thanks !!

Jan


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.