abiieez
abiieez

Reputation: 3189

Hibernate constraints on Embeddable class

I have the following entity

@Entity
@Table(name = "item")
public class Item implements Serializable {

    @Embeddable
    public static class ItemPK implements Serializable {
        private static final long serialVersionUID = 3795221679277433625L;

        @ManyToOne
        @JoinColumn(name = "country_id")
        private Country country;

        @NotEmpty
        @Length(min = 3)
        private String name;
...
...
}

I notice that the @NotEmpty constraint is never being tested during validation. How can I enforce the validation on that field ?

Upvotes: 1

Views: 352

Answers (1)

Hardy
Hardy

Reputation: 19119

Do you use @Valid on the ItemPK field in Item? It would help if you update your example code.

Upvotes: 2

Related Questions