-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate ... fetch groups
PostPosted: Mon Dec 13, 2004 12:47 pm 
Newbie

Joined: Mon Dec 13, 2004 12:37 pm
Posts: 18
My understanding is that lazy initialization works such that once any field is retrieved hibernate retrieves all fields in a class mapping.

I have a persistent class which has mappings to several other persistent classes. I do not necessarily need all of the relations each time I use the persistent class, so I am wondering if their is any way to work around this issue (other than defining mappings without the relations)?

I have worked a good deal with Kodo JDO and they provide fetch groups to solve this issue. Are their any plans to put a feature like this into Hibernate?

Thanks,
Thomas

PS I did a quick search on this topic before posting and didn't see the answers I was looking for. However if these questions have been asked and answered a million times I apoligize as I am new to following this group.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 1:37 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
My understanding is that lazy initialization works such that once any field is retrieved hibernate retrieves all fields in a class mapping.


wrong

if you have
A--1B
|
|
1
C

and B and C are proxied, B will be loaded only when needed, the same for C

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 5:05 pm 
Newbie

Joined: Mon Dec 13, 2004 12:37 pm
Posts: 18
Not quite sure I understand how proxies make that work.

It seemed to me that you could define a proxy for class A, B, and C.

The documentation also seemed to sound like the "lazy" setting acted pretty much like a proxy with the actual classs.

In any case we have A, B, and C lazy, but when you retrieve any field from A (relation or not) both B and C are also retrieved. We arent using any proxies

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 5:50 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
In any case we have A, B, and C lazy, but when you retrieve any field from A (relation or not) both B and C are also retrieved. We arent using any proxies


wrong too ;)

let's continue with my previous example
1- mark B and C classes with lazy="true" (class level mapping as you said)
2- in A mapping file, you just need to set outer-join="auto" in the two many-to-one association.

if you do this, you'll see that B and C won't be loaded until you call a.getB() or a.getC();

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 13, 2004 10:53 pm 
Regular
Regular

Joined: Fri Nov 12, 2004 12:07 am
Posts: 57
Location: Beijing,China
Quote:
2- in A mapping file, you just need to set outer-join="auto" in the two many-to-one association.


It should be one-to-many,hmmmm


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 3:09 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
nop,
tyagel and i were talking about to-one lazy loading

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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