[
http://opensource.atlassian.com/projects/hibernate/browse/HV-535?page=com...
]
Jesse Hutton commented on HV-535:
---------------------------------
I spoke with sebersole on #hibernate, and he claimed that hibernate cannot do anything
about this and that it must be done in HibernateValidator. Here is the problem:
Child child = em.find(Child.class, id);
Parent parent = child.getParent();
validator.validate(parent); <-- constraint violations!
This fails when:
A) parent is a proxy because it was specified as FetchType.LAZY in the JPA configuration
B) Parent uses field level BV annotations
In order to hit the bug, both A and B have to be true. A is done by Hibernate, and B is
done by HibernateValidator.
I've simply moved all my BV annotations to methods. However, I think that this should
be handled transparently for new users or at least clearly documented and warnings emitted
somewhere when field level BV annotations are used in an entity class that Hibernate
expects to create proxies of.
Validator sees all nulls on proxy object when proxied entity class
has constraint annotations applied to fields instead of methods
----------------------------------------------------------------------------------------------------------------------------------
Key: HV-535
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HV-535
Project: Hibernate Validator
Issue Type: Bug
Affects Versions: 4.1.0.Final, 4.2.0.Final
Environment: RHEL 6.1
Reporter: Jesse Hutton
When hibernate creates a proxy of an entity relation (eg. when FetchType.LAZY is
specified on a @ManyToOne relationship) and the Bean Validation annotations have been
applied on the proxied class to fields instead of methods, the validator can't see any
values. All it sees are nulls.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira