Hello, I am attempting to use Hibernate Validator on my project (3.0.0ga with Hibernate 3.2.1).
I have several entities that contain components (i.e. a POJO with the @Embeddable annotation). I also have domain objects that inherit from a superclass POJO that contains auditing fields e.g. last updated time, last updated user etc.
The problem I am experiencing is that the DDL generated by Hibernate Validator is ignoring the validator annotations on the components and superclass fields e.g.
Code:
@Entity(table = "myTable")
public class MyEntity {
...
@Embedded
@Valid
public Address getAddress() {
return address;
}
@Column(name = "myColumn")
@Length(max = 10)
@NotNull
public String getMyColumn () {
return myColumn;
}
}
@Embeddable
public class Address {
...
@Column(name = "city")
@Length(max = 20)
@NotNull
public String getCity() {
return city;
}
}
When hbm2ddl runs it generates something similar to the following DDL
Code:
create myTable (
city varchar(255) null, <-- should be varchar(20) not null
myColumn varchar(10) not null
)
i.e. Hibernate Validator has correctly applied the Validator annotations to the fields in MyEntity but it has ignored the validator annotations on the embedded Address component.
I have a similar issue with inherited properties i.e. the validator annotations on those properties are ignored in the generated DDL. The actual validation of the components and inherited properties *is* working - its just that the generated database schema is wrong.
Is this just a limitation of Hibernate Validator or is it supposed to be able to generate the correct DDL for components and inherited properties (i.e. have I configured something wrong)?