How would I go about wanting to generate a default message template for a constraint (in a JPA entity) if no such message template is already defined on the annotation itself.
Here's what I mean. Suppose I have a JPA entity 'Dummy':
@Entity
public class Dummy {
@Column
@NotNull
Long id;
}
Also, suppose I have a ValidationMessages.properties file containing:
Dummy.id.NotNull=ID of dummy should not be null
Now, if I defined the @NotNull constraint as @NotNull(message={Dummy.id.NotNull}) all would work well, but what if I wanted to to generate the '{Dummy.id.NotNull}' template on the fly (using reflection) so I don't have to write the same standardized template on each and every constraint? I tried this using the MessageInterpolator class, but the interpolation method gets called only when the message attribute is defined, and this defeats the purpose of what I'm trying to do.
So, to make myself clear, how do I make the validator ask a chunk of my code "hey, what's the message for the constraint 'NotNull' on the field 'id' in the class 'Dummy' even though it has no message assigned (or rather, it has the default message assigned)?"