Search code examples
jpaeclipselinkbean-validation

how to enable throws exception using JPA 2.1 and eclipseLink 2.5.2


I'm using JPA 2.1 and i want to enable to throws exception from entity when validation failed this is field on my entity i have to create <h:messages /> to my JSF page to show this problem and i can't handle it in another way.

How I can throw the exception if I didn't put value in this field?,

I want to know how I can enable the exception and I will handle this exception

@Size(min = 1, max = 100)
@Column(name = "room_name")
private String roomName;

Solution

  • How I can throw the exception if I didn't put value in this field?


    In adding @NotNull Constraint

    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "room_name")
    private String roomName;