Hi,
I am trying to save a validated (Validator 4.0.1.GA) entity (hibernate-core 3.5.0-Beta-2) that holds a Map<K, V> of other persisted entities.
I have written a custom ConstraintValidator that handles the validation of such a Map<K, V> (just checking wether the map holds some predefined values).
I can validate the map "by hand" using validator.validate() in my unit tests and the map is correctly filled at validation time.
However when validation framework is called by persistence callbacks, the map is always empty...
I tryed to pinpoint the problem and it seems that the map is not touched in the following method of AbstractType during the merge :
Code:
public Object replace(
Object original, Object target, SessionImplementor session,
Object owner, Map copyCache, ForeignKeyDirection foreignKeyDirection) throws HibernateException {
boolean include;
if ( isAssociationType() ) {
AssociationType atype = (AssociationType) this;
include = atype.getForeignKeyDirection()==foreignKeyDirection;
}
else {
include = ForeignKeyDirection.FOREIGN_KEY_FROM_PARENT==foreignKeyDirection;
}
return include ? replace(original, target, session, owner, copyCache) : target;
}
Am I doing something wrong or trying to do something not allowed by persistence or validation spec?
Perhaps it is a bug in the Beta version?
Can I get some feedback please?