On 15 mai 2012, at 12:38, Hardy Ferentschik wrote:
Is option #3 even possible within the JPA spec? One would need meta
information about the id property
(which generation type and how exactly this type behaves regarding the id generation
time). I don't think there
is a way to do this with the JPA api. Also JPA does not even explicitly define the
behavior of the different strategies.
Remember that the TraversableResolver used in pre-* events is implemented by the JPA
provider itself. It's very easy for the implementation
to tap provider specific metadata (most likely not exposed). We don't need JPA to
expose the API.
Disabling the validation per default can also backfire in the cases where a user
"knows" that a certain strategy
will generate the id pre insert. In this case it would be valid to add @NotNull.
True but that would definitely make the application non portable from a JPA point of
view.