Skip to content

Commit

Permalink
Use ParameterMessageInterpolation to get rid of hibernate error with …
Browse files Browse the repository at this point in the history
…missing dependency
  • Loading branch information
micryc committed Nov 4, 2024
1 parent 63714c6 commit 877e4d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {{invokerPackage}}.ProgressRequestBody;
import {{invokerPackage}}.ProgressResponseBody;
{{#performBeanValidation}}
import {{invokerPackage}}.BeanValidationException;
import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator;
{{/performBeanValidation}}

import com.google.gson.reflect.TypeToken;
Expand Down Expand Up @@ -42,6 +43,7 @@ import javax.validation.executable.ExecutableValidator;
import java.util.Set;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator;
{{/performBeanValidation}}

{{#imports}}import {{import}};
Expand Down Expand Up @@ -165,7 +167,10 @@ public class {{classname}} {
{{/performBeanValidation}}
{{#performBeanValidation}}
try {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
ValidatorFactory factory = Validation.byDefaultProvider()
.configure()
.messageInterpolator(new ParameterMessageInterpolator())
.buildValidatorFactory();
ExecutableValidator executableValidator = factory.getValidator().forExecutables();
Object[] parameterValues = { {{#parameters}}{{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}} };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import javax.validation.executable.ExecutableValidator;
import java.util.Set;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator;
{{/performBeanValidation}}

{{#imports}}import {{import}};
Expand Down Expand Up @@ -147,7 +148,10 @@ public class {{classname}} {
{{/performBeanValidation}}
{{#performBeanValidation}}
try {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
ValidatorFactory factory = Validation.byDefaultProvider()
.configure()
.messageInterpolator(new ParameterMessageInterpolator())
.buildValidatorFactory();
ExecutableValidator executableValidator = factory.getValidator().forExecutables();
Object[] parameterValues = { {{#parameters}}{{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}} };
Expand Down

0 comments on commit 877e4d9

Please sign in to comment.