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:
Code:
@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:
Code:
@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.
Anyone got an idea?
Thanks,
Jeff