Hello,
Need some help.
Lazy loading for OneToOne and ManyToOne relationships works with no issues if a column is not nullable (nullable = false). In case of nullable column (nullable=true) Hibernate throws "org.hibernate.UnresolvableObjectException: No row with the given identifier exists:.." exception while it retrieves null from DB. So It seems that @NotFound(action = NotFoundAction.IGNORE) doesn't do what it supposed to.
Works with no issues:
Code:
@OneToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "EMPID", referencedColumnName = "EMPLOYEETMSID")
@LazyToOne(LazyToOneOption.NO_PROXY)
@NotFound(action = NotFoundAction.IGNORE)
public Employee getEmployeeSE() {
return employeeSE;
}
Throws exception when retrieve Null:
Code:
@ManyToOne(fetch = FetchType.LAZY, optional = true)
@JoinColumn(name = "MANAGER", nullable = true)
@LazyToOne(LazyToOneOption.NO_PROXY)
@NotFound(action = NotFoundAction.IGNORE)
public EmployeeTms getManager() {
return this.manager;
}
public void setManager(EmployeeTms manager) {
this.manager = manager;
}
How can I avoid "org.hibernate.UnresolvableObjectException: No row with the given identifier exists:.." exception?
--
Thanks,
Eugene