Im using
- hibernate-core-4.0.1.Final
- hibernate-validator-4.2.0.Final
I have a lazy loadable Entity
@NotNull
@OneToOne(fetch = FetchType.LAZY,optional = false,cascade = CascadeType.PERSIST)
@JoinColumn(name="library_id")
private Library library;
public Library getLibray() {
return library;
}
and a defaultValidator
private final ValidatorFactory factory = Validation
.buildDefaultValidatorFactory();
private final Validator val = factory.getValidator();
When I am trying to validate unattached and attached Entitys annotated with @NotNull, @Size
and so forth.
Everything works fine. But when i load an Entity via Lazy Load and try to validate it.
The Validator fails every time. This seems due to the fact that im getting a Hibernate Proxy Object.
I can get arround this "issue" easily by just unproxying it.(But this is not so favorable in my situation)
Is this the expected behavior? Do I get the same behavior in OpenJPA, EclipseLink....?
Have a nice Sunday guys ;) I hope i did make the Question clear?