Hi all.
I need to validate the fields of an embedded-annotated class.
I have the following structure:
Code:
@Entity
@Table(name = "table_A", schema = "my_schema")
public class A implements Serializable {
private B b = null;
@Embedded
public B getB() {
return b;
}
public void setB(B b) {
this.b = b;
}
}
@Embeddable
public class B implements Serializable {
private String field = null;
@Column(name = "b_field")
@Length(min = 5, max = 10)
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
}
When I create an A object with a B object with a 'field' field length less than 5 or greater than 10, validator does not detect the constraint violation... Example:
Code:
A a = new A();
B b = new B();
b.setField("");
//b.setField("string longer than 10 characters");
a.setB(b);
I know my validation configuration is right because if I try to validate other fields in A class, but not @Embeddable, it rights fine.
Is there any problem with @Embeddable fields validation?