I write custom message interpolation. I want that JPA will use my custom message interpolation. Here http://docs.jboss.org/hibernate/validator/4.2/reference/en-US/html/validator-bootstrapping.html#section-message-interpolator I found following description:
Configuration<?> configuration = Validation.byDefaultProvider().configure();
ValidatorFactory factory = configuration
.messageInterpolator(new ValueFormatterMessageInterpolator(configuration.getDefaultMessageInterpolator()))
.buildValidatorFactory();
Validator validator = factory.getValidator();
but where I should write such a code? In the web.xml in init-servlet? Can I provide such code in persistance.xml?
P.S. I copy&paste the code. In my case line
ValueFormatterMessageInterpolator(configuration.getDefaultMessageInterpolator()))
will be change on something like this
CustomMessageInterpolator(configuration.getDefaultMessageInterpolator()))
see also How do I dynamically resolve message parameters with Hibernate Validator?