This page is an old working document and is probably out of date.
Introduction
This document describes how Hibernate currently behaves in Hibernate ORM master branch with various mappings for lazy @OneToOne/@ManyToOne.
It also describes possible improvements.
Unidirectional one-to-one:
@Entity
public class Owner {
@OneToOne( fetch = FetchType.LAZY )
private Lazy lazy;
}
Join Column | @LazyToOne Mapping | hibernate.enhancer.enableLazyInitialization = false | hibernate.enhancer.enableLazyInitialization = true |
---|---|---|---|
FK references PK of associated entity | not specified | Is Owner#lazy initialized by Session#get( Owner.class, id )? false Is Owner#lazy a HibernateProxy? true | |
LazyToOneOption.FALSE | Is Owner#lazy initialized by Session#get( Owner.class, id )? true (separate statement) Is Owner#lazy a HibernateProxy? false
Improvement: log a warning: <association-path> is mapped as | Is Owner#lazy initialized by Session#get( Owner.class, id )? true (separate statement) Is Owner#lazy a HibernateProxy? false
Improvement: log a warning: <association-path> is mapped as | |
LazyToOneOption.NO_PROXY | Is Owner#lazy initialized by Session#get( Owner.class, id )? true Is Owner#lazy a HibernateProxy? false
| Is Owner#lazy initialized by Session#get( Owner.class, id )? false Is Owner#lazy a HibernateProxy? false | |
LazyToOneOption.PROXY | Equivalent @LazyToOne not specified. | Is Owner#lazy initialized by Session#get( Owner.class, id )? yes Is Owner#lazy a HibernateProxy? false
| |
FK references non-PK of associated entity | not specified | ||
LazyToOneOption.FALSE | |||
LazyToOneOption.NO_PROXY | |||
LazyToOneOption.PROXY |
Comments