Interesting.
I think my original post was a little blunt :)
My project already uses JPA and Hibernate annotations, so we already have the @Column annotations with nullability and length set on them. These parameters are used to generate the DDL, which works just brilliantly. Now we want to add validation to the app and it seems that validation needs a whole new set of annotations?
I guess what I am asking is, what is the difference, both in terms of what the hibernate tools sees, and what hibernate runtime sees between the following declarations:
@Column(name="Foo", length=20, nullability=false)
private String name;
and
@Column(name="Foo")
@Length(max=20)
@NotNull
private String name;
I prefer the terseness of the former declaration, but the Hibernate Validator doesn't appear to look at the @Column annotation to derive max length and nullability information.
Also, what would be the result if conflicting parameters were set?
i.e.
@Column(name="Foo", length=20, nullability=true)
@Length(max=40)
@NotNull
Would the hibernate toolset only read the column annotation to generate the DDL, and leave the Validator to use the Length and NotNull annotations, or would the presence of a Length annotation trump the length parameter in the Column annotation?
|