I have the mapping in the user class:
@NotNull(message = "Contato não pode ser vázio.")
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "contact_id")
@Getter
@Setter
private Contato contato;
Which has the class JsfExceptionHandler
that captures all the exceptions of the application. I made the treatment for constraint violations
errors, however I need to display only the validation message and not all the error text as it is happening.
Message that is being displayed:
Validation failed for classes
[br.com.openfiscal.model.Usuario] during persist time for groups
[javax.validation.groups.Default, ]
List of constraint violations:
[ ConstraintViolationImpl{interpolatedMessage='Contato não pode ser vázio.',
propertyPath=contato, rootBeanClass=class br.com.openfiscal.model.Usuario,
messageTemplate='Contato não pode ser vázio.'} ]
I want to display only messageTemplate
.