[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5143) Lazy Loading Not Working for @OneToOne Associations With LazyToOneOption.PROXY
j nadler (JIRA)
noreply at atlassian.com
Tue Apr 27 01:59:33 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36701#action_36701 ]
j nadler commented on HHH-5143:
-------------------------------
I tried Shareth's suggestion from HHH-5109 here and it's no help in this case. I actually don't think HHH-5109 is a real bug (the submitter just forgot the "optional=false"). Obviously I do think that this one is a real bug, though I'd be happy to be proven wrong :)
> 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
> Attachments: OneToOneLoadTest.java
>
>
> 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