Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Component/s: DSL for Business Domain
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
MODFORJ-98 could be worked around by implementing setComestible in the extension point and calling the validation from there. However, this doesn't work because of another issue; the validators are not set when Hibernate restores the object from the database, since the protected no-arg constructor doesn't do anyting.
When a new Part is created, first a Part with empty relations is created and persisted in the database. A split second later this Part is retrieved from the database again, setComestible is invoked and the validators are called. Because the list of validators is empty, validation always succeeds.
Makes me wonder if anyone has ever seen validation working when updating an existing domain object?
Issue Links
| This issue relates to: | ||||
| MODFORJ-98 | validate method is not called in setter of domain object. |
|
|
|
You're right, the default no-arg constuctor does not
unlike the constructor with argumentsset the needed validators.What we could do:
validation.addValidator(new NotNullValidator(Part.class, "quantity"));
validation.addValidator(new PartCheckMinimumQuantity());
This could also apply as workaround. Just implement it in your extension points.
unlike the constructor with argumentsset the needed validators. What we could do:- In the DomainClassImplBase classes add a new method called setValidators(). This method adds all needed validators to the validation instance variable:
validation.addValidator(new NotNullValidator(Part.class, "quantity"));
validation.addValidator(new PartCheckMinimumQuantity());
- Call this method in all constructors including the no-arg constructor. This would replace the current individual adds to the validator in the constructors. After this add a validation.validate();
This could also apply as workaround. Just implement it in your extension points.