-->
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: getId overrides lazy-loading?
PostPosted: Wed Sep 24, 2008 12:25 pm 
Newbie

Joined: Wed Sep 24, 2008 11:53 am
Posts: 2
Dear all,

I am a bit confused about the lazy loading mechanism.

My environnement is the following:
- JPA as API
- Hibernate as implementation with
hibernate-3.2.4.jar
hibernate-entitmanager-3.3.1.ga
hibernate-annotations-3.3.0.ga
My test is very simple.

1°) domain object model
Two domain objects Employee and Coordonnes, with an association One-to-One (unidiretional) between the two ones and coordonnees association configured to be lazy-loaded.
Below is an excerpt:

Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Employee implements Serializable {
...


@OneToOne(fetch=FetchType.LAZY)
private Coordonnees coordonnees;


}


2°) navigation:
Two screens, the first one to make a search on list of employees based on
search criteria and the seconf to display the results.

a) When i do the research, Hibernate runs well and loads a runtime proxy for the association entity coordonnees.
b) What i wonder is why Hiberate makes the whole SQL request on this proxy even if the only property asked on this object in the jsf page is the identifier property
In the debugger, it's very clear that when the employee.coordonnees.getId() is called that Hibernate makes the proxy fully loaded by hinting the db.

Code:
<rich:column>
   <f:facet name="header">
      #{messages['employe.identifiant.header']}
   </f:facet>
       #{employe.coordonnees.id}
</rich:column>


here's the sql order generated by hibernate:
Code:
[24/09/08 17:43:16:187 CEST] 00000028 SystemOut     O Hibernate:
    /* load com.natixis.demosphinx.exemples.jpa.employe.metier.Coordonnees */ select
        coordonnee0_.YCOIDN as YCOIDN0_0_,
        coordonnee0_.LADRT1 as LADRT2_0_0_,
        coordonnee0_.LCPITL as LCPITL0_0_,
        coordonnee0_.COTLP1 as COTLP4_0_0_,
        coordonnee0_.LVILTL as LVILTL0_0_
    from
        SPHINX_IDE_TEST_JPA_COORDONEES coordonnee0_
    where
        coordonnee0_.YCOIDN=?


I am just surpised that Hibernate needs to fully load the proxy when only it's identifier is called (because the proxy is alreeady supposed to hold this property). I thought it was only necessary when others properties were asked.
Did i miss something?
Thanks for your response,
Regards[/b]


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.