Skip to Content
Nov 02, 2020 at 03:21 PM

Issue with Dynamic Constraint - Validation engine returns random Dynamic Constraint

307 Views Last edit Nov 02, 2020 at 03:40 PM 6 rev

Hello All,

We are observing a strange behaviour for Custom Dynamic Constraints, where validation engine is picking the first available dynamic constraint from Iterator for given annotation class and not the one return by ConstraintViolation, which caused constraint violations to display in the Backoffice ( Product Cockpit ) incorrectly.

We have created the dynamic constraints through impex and used below annotation for all the constraints.


But as per the OOTB logic , It looks like Hybris is expecting unique annotation class for each new Dynamic constraint.

Did anyone came across this kind of scenarios ? and if yes , what should be the suitable solution?

Currently we are using Hybris1808.

Looking for your help if you have any view or experience on this topic. Thanks in advance :)

OOTB class to build the constraints models.


private AbstractConstraintModel buildConstraintModel(ConstraintViolation constraintViolation) {
    AbstractConstraintModel result = null;
    Object model = constraintViolation.getLeafBean();
    if (model instanceof ItemModel) {
        String type = this.modelService.getModelType(model);
        TypeModel typeModel = this.typeService.getType(type);


while(var14.hasNext()) {
    AbstractConstraintModel attribConstraintModel = (AbstractConstraintModel);
    if (attribConstraintModel.getAnnotation().equals(annotationClass)) {
        result = attribConstraintModel;