]
Gail Badner resolved HHH-5143.
------------------------------
Assignee: Gail Badner
Resolution: Rejected
If you or someone opens a new issue with a patch for logging this, I'll apply it.
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
Assignee: Gail Badner
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: