Hi Rich,
I don't think this is a Hibernate Validator (Bean Validation) issue. Here is what the spec says:
Quote:
For each event type, a list of groups is targeted for validation. By default, the default Bean Validation group (the group Default) will be validated upon the pre-persist and pre-update lifecycle validation events, and no group will be validated upon the pre-remove event.
On pre-persist your orderid is still null and hence the validation error. Bean Validation does not have any knowledge about JPA and that this is a generated value which will be set (and neither should it).
One solution is obviously to disable lifecycle based validation via the
javax.persistence.validation.mode property. And alternative would be to work w/ validation groups and use the properties
javax.persistence.validation.group.pre-persist/pre-update/pre-remove. Personally I think the
@NotNull is not useful in this case.
--Hardy