Hi,
I set Fetchtype.LAZY for my OneToOne relationships on both sides of the relationship.
I turn on SQL tracing. I read one side of the relationship into memory using em.refresh() or em.find(), hibernate still executes multiples SQL statements to read the specific entity and any tables (i.e. other entities) that it may be associated to.
My objective is to only read the actual Entity into memory no relationships as this introduces a performance problem.
Any ideas?
the relavant code is:
Code:
@Entity
public class Address {
private Company company;
// One to One Rel
@OneToOne(mappedBy="address", fetch=FetchType.LAZY)
public Company getCompany(){
return company;
}
public void setCompany(Company company){
this.company = company;
}
}
@Entity
public void Company {
private Address address;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="I_ADDRESS_ADDRESS", referencedColumnName="I"),
@JoinColumn(name="C_ADDRESS_ADDRESS", referencedColumnName="C")})
public Address getAddress() {
return address;
}
public void setAddress(Address address){
this.address = address;
}
}