-->
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: Lazy Loading change proposal
PostPosted: Wed Dec 16, 2009 4:04 am 
Newbie

Joined: Wed Dec 16, 2009 3:58 am
Posts: 1
Hello,
welcome everybody this is my first post on the forum, so if I do something wrong, don't kill me ;)

I have little proposal for lazy loading:

Suppose I have entity
@Entity
Public class Boss {
private Long id;
private @ManyToOne() Company company;
}
and I try to load Boss entity by primary key form DB:
Sesion s = …;
Boss boss = s.get(Boss.class, 1l); //get by pk
When I try to get company’s id, as I understand, the proxy will load FULL Company entity, not only ID that I only wanted.
Boss.getCompanty().getId();
Company’s id is in the same table as Boss, and it has been loaded into memory, lazy loading needs to know what to load when user call getCompany(). Lazy loading should load full entity only when I try to get other field than PK, not the entity itself (not boss.getCompany() ) .
So if I call:
Boss boss = s.get(Boss.class, 1l);
the empty Company entity should be filled with PK field, when I want to access any other field, the layzy loading should then load the full entity.

It can be accomplished through HQL, should maybe it could be done through API.
Any comments?


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.