Java – how to find bean validation errors in NetBeans
I created an EJB Session Facade in NetBeans 7 to store my entities
public class Insurance{ @ManyToOne(optional=false) @JoinColumn(name="PLAN_ID") private RatePlan plan; } public class RatePlan{ @OneToMany(mappedBy="plan") private Set<Insurance> insuranceItems; }
When I try to save my EJB session bean in my database, I encounter the following error
Result: javax validation. Constraintviolationexception: the bean validation constraint: 'prepersist' was violated when the callback event performed automatic bean validation For more information, see embedded constraints
What I do is in my persistence Turn off my bean validation in the XML file I want to know what bean validation error happened, but I don't know how or where to find it or how to configure and capture it
My EJB facade is a simple class like t
public class InsuranceFacade{ public void saveInsurance(Insurance insurance){ em.persist(insurance); } }
Any tips?
Solution
To know what specific constraint violations have occurred, you can check the caught exceptions ConstraintViolationException. Getconstraintviolations () returns a set of constraintviolations that you can iterate and check