[
https://hibernate.onjira.com/browse/HV-586?page=com.atlassian.jira.plugin...
]
Hardy Ferentschik commented on HV-586:
--------------------------------------
I think you just found the answer to your question yourself. _@NotEmpty_ will initialize
the proxy, because it needs to check the size of the set.
One solution could be to map the collection extra lazy (Hibernate specific feature) in
which case only the size of the collection gets queried:
{code}
class A {
@OneToMany
@LazyCollection(LazyCollectionOption.EXTRA)
@Valid
@NotEmpty
private Set<B> b;
}
{code}
I think you still will need a open session though. This is something which is always
needed when working with lazy collections.
Hibernate validator initializes lazy proxies
--------------------------------------------
Key: HV-586
URL:
https://hibernate.onjira.com/browse/HV-586
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 4.2.0.Final
Environment: CentOs, Glassfish V3
Reporter: Michael G
Priority: Critical
I use hibernate validator for detached entities, some of them are not initialized. If
they are not initialized imho there is no possibility that they could have been changed so
that constraints might be broken. Although hibernate validator goes for them and I get
LazyLoadingExceptions.
Also this is a change to previous versions. Has that been done on purpose?
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira