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: lazy loading with one-to-one or many-to-one associations
PostPosted: Sun May 09, 2004 7:41 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
suppose I have

class A : Long id, B b

class B: Long id, String name

table A: ID

table B: ID, A_ID, Name

where A_ID is the foreign key references A.

here I want to move from class A with a lazy loading of matched B object
session. find("Select from A");


mapping filez:
<class name = "A" table= "A" ...>
<id.....
</class>

</class name ="B" table "B" ...>
<id.......
</class>

Here in mapping files where and how I have to put one-to-one or many-to-one association to load A objects and matching B's(lazy) when I query on A;

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 09, 2004 3:00 pm 
Newbie

Joined: Sat Oct 11, 2003 1:47 pm
Posts: 17
session. find("Select new A(a.id) from A a");

will only return the ID column when you do the find and not load the B Object which it wud if you enter ur original query.

Hope this is what u are looking for

Cheers
Raja


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 2:55 am 
Senior
Senior

Joined: Sun Mar 14, 2004 10:16 am
Posts: 129
Location: Ankara
raja05 wrote:
session. find("Select new A(a.id) from A a");

will only return the ID column when you do the find and not load the B Object which it wud if you enter ur original query.

Hope this is what u are looking for

Cheers
Raja


No raja, that is not the one I am looking for.
Thanks still

_________________
-developer


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 10, 2004 3:34 am 
Newbie

Joined: Fri May 07, 2004 4:34 am
Posts: 5
I think that your DB model is not correct : your foreign key should be on table A.

class A : Long id, B b
and class B: Long id, String name

should give the following tables :

table A: ID, B_ID
table B: ID, Name


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.