I ave observed the following in the case on JPA-HIbernate one to one association :
When one to one association using Lazy fetch - It fires SELECT queries
class A {
@OneToOne(fetch = FetchType.LAZY, mappedBy = "a", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
public B getB() {
return B;
}
}
When one to one association using EAGER fetch - It fires JOIN queries
class A {
@OneToOne(fetch = FetchType.EAGER, mappedBy = "a", cascade = { CascadeType.PERSIST, CascadeType.MERGE })
public B getB() {
return B;
}
}
What I have observed is in case 1, also there is nothing lazy but the SELECT queries are fired almost immediately when the parent entity is loaded.
Does lazy load really work in case default configurations in JPA-Hibernate or it is always EAGER with SELECT/JOIN queries ?