Trying to take a look at Bean Validation, I have substituted many of the JPA annotations with BV annotations in a project. However, the generated database schema does not match.
One of the problems is that it does not work with element collections. The resulting columns do not have any of the specified constraints.
Taking a look at the Hibernate code (not that I have much idea) I have found "org.hibernate.cfg.beanvalidation.TypeSafeActivator". There, in "private static void applyDDL(String prefix, ..." there is a comment that says "//FIXME add collection of components" (
github link). So, may be, DDL generation is not fully supported a this time?
I have also spotted more differences (although they might be my fault):
- All columns of an Embedded are set to not null when nor the Embedded attribute nor the Embeddable attributes are annotated with @NotNull.
- A simple String attribute only annotated with @Digits is set as not null.
- Some join columns are nullable even with @NotNull annotations.