[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HHH-5143) Lazy Loading Not Working for @OneToOne Associations With LazyToOneOption.PROXY

j nadler (JIRA) noreply at atlassian.com
Fri Apr 23 15:56:33 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36668#action_36668 ] 

j nadler edited comment on HHH-5143 at 4/23/10 2:54 PM:
--------------------------------------------------------

I can grab the source and debug this prooblem on my end since it seems difficult to reproduce in a trivial project.  Can anyone suggest where I start looking:
The first thing I'd like to do is to confirm that the properties are being lazy loaded (rather than being loaded by an event listener related to Hibernate Search, for example).   Where would I add some logging statements to make this clear?  

      was (Author: jnadler):
    I can grab the source debug this on my end since it seems difficult to reproduce in a trivial project.  Can anyone suggest where I start looking:
The first thing I'd like to do is to confirm that the properties are being lazy loaded (rather than being loaded by an event listener related to Hibernate Search, for example).   Where would I add some logging statements to make this clear?  
  
> Lazy Loading Not Working for @OneToOne Associations With LazyToOneOption.PROXY
> ------------------------------------------------------------------------------
>
>                 Key: HHH-5143
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5143
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.1
>         Environment: Hibernate Core 3.5.1-Final, MySQL 5.1
>            Reporter: j nadler
>
> I'm using 3.5.1. Two persistent entities, parent and child, are in a one to one relationship:
> In Parent, the reference to Child:
>    @OneToOne(optional=false, fetch=FetchType.LAZY, cascade={ CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH, CascadeType.PERSIST })
>    @LazyToOne(LazyToOneOption.PROXY)
>    @JoinColumn(name = "childId")
>    @ForeignKey(name="FK_Parent_Child")
>    @IndexedEmbedded()
>    public Child getChild() {
>       return child;
>    }
>    public void setChild(Child child) {
>       this.child = child;
>    }
> And in Child, the reference to Parent:
>    @OneToOne(mappedBy="child", fetch=FetchType.LAZY)
>    @LazyToOne(LazyToOneOption.PROXY)
>    @ContainedIn 
>    public Parent getParent() {
>       return parent;
>    }
>    public void setParent(Parent parent) {
>       this.parent = parent;
>    }
> When I load a Parent entity via HQL, I see three SQL queries:
> -one that corresponds to my HQL query
> -one that loads Child
> -one that loads Parent from the Child's perspective
> I'm watching it in JProfiler and it's hurting our app performance significantly because Child contains LOBs that are rarely needed.
> I tried making it a unidirectional association (no reference from Child back to Parent) but the expensive SQL call (loading Child) still happens.  That gets it down to two SQL queries:
> -one that corresponds to my HQL query
> -one that loads Child (the expensive one)
> We are using the stock javassist proxies and no bytecode enhancement.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list