I'm using Hibernate with JPA and have a relationship that looks like this:
public class PencilImpl implements Pencil {
@ManyToOne(targetEntity = PersonImpl.class, fetch = FetchType.LAZY)
@JoinColumn(name = "owner", nullable = false)
private Person owner;
...
@Override
public final Person getOwner() {
return owner;
}
}
Since I started using the LAZY fetch type, everytime I try to get a pencil's owner (pencil.getOwner) I get a non-null object that has all of it's inner properties set to null.
I looks like the proxy created by Hibernate is not fetching the real object from the database when it should.
Any ideas? Thanks :)
As JB Nizet suggested, the final modifier in my classes' getters was messing with the proxies hibernate creates for lazy loaded relationships.