Given the following mappings:
{code:java} @Entity(name = "EmployerInfo") public static class EmployerInfo { @Id private int id;
@MapsId @OneToOne(optional = false, fetch = FetchType.LAZY) @LazyToOne(LazyToOneOption.NO_PROXY) private Employer employer;
private String info; }
@Entity(name = "Employer") public static class Employer { @Id private int id;
@OneToOne(optional = false, fetch = FetchType.LAZY, mappedBy = "employer", cascade = CascadeType.ALL) @LazyToOne(LazyToOneOption.NO_PROXY) private EmployerInfo employerInfo;
private String name; } {code}
Assuming enhacement-as-proxy is enabled ({{hibernate.bytecode.allow_enhancement_as_proxy=true}}), when an {{Employer}} is loaded, {{Employer#employerInfo}} is not initialized as an enhanced proxy. It is lazily loaded when accessed. |
|