[bv-dev] BVAL-234 @NotNull @Id for JPA and Bean Validation
Gunnar Morling
gunnar.morling at googlemail.com
Mon May 21 15:06:58 EDT 2012
2012/5/21 Emmanuel Bernard <emmanuel at hibernate.org>:
>
> On 15 mai 2012, at 19:50, Gunnar Morling wrote:
>
>> I also find disabling validation of @NotNull by default problematic.
>> If I'm for instance using sequences for id generation, then @NotNull
>> should be validated upon insertion. But relying on sequences is IMO
>> per se not portable; so when deciding to use them, I'd also expect
>> @NotNull to be validated.
>
> I think you misunderstood something. If sequence, table generation or any in memory generation logic is used, then @NoNull will indeed be validated in option #3. In fact, database trigger and column id generations are the only one that would disable validation.
Ah, I see. Indeed I thought that you meant to disable validation of
@NotNull in any case. If the behavior depends on the applied id
generation strategy, #3 makes more sense.
I'm not sure, does the JPA spec define that sequence values are always
to be prefetched? Otherwise I could imagine situations where an
allocation size of 1 is used, which would allow to fetch the sequence
just within the INSERT statement. In that case I think the constraints
again couldn't be validated.
--Gunnar
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev
More information about the beanvalidation-dev
mailing list