I forced an error on my system that contains the following message:
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
It is a constraint violation. How can I customize to display an example persoanlized message: Warning: This name already exists in the database.
I even created a class for Messages and it has this method:
public static void erro(String mensagem) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, mensagem, "");
FacesContext.getCurrentInstance().addMessage("messagePanel", msg);
}
Thank you in advance.