[hibernate-dev] ORM DDL doesn't reflect BV constraints with validation mode CALLBACK
gunnar at hibernate.org
Tue Feb 6 08:52:00 EST 2018
2018-02-06 14:41 GMT+01:00 Steve Ebersole <steve at hibernate.org>:
> The reasoning is that the 2 BV modes you mention make no mention of also
> applying constraints to the database. It would be surprising for that to
> happen. I can see the argument for AUTO, but absolutely not for CALLBACK.
I think that a) "trigger validation upon insert/update" and b) "propagate
constraints to the DDL" are two separate concerns which should be handled
I.e. ideally I'd keep the "validation mode" property solely focused on a)
(i.e. not have that DDL enum member) and control b) (which is as you say
not defined by the spec) via a separate property. In fact, ORM already has
a property applying to b), "hibernate.validator.apply_to_ddl", although it
seems linked to "legacy Hibernate Validator" as per a log statement in
> Also important is the distinction that hibernate accepts multivalued
> validation modes, whereas BV does not if I remember correctly... Although
> in my opinion it absolutely should.
"validation mode" is defined by JPA, not BV. As per above I don't think it
needs to be multi-valued, those two aspects can be handled separately.
> On Tue, Feb 6, 2018, 7:35 AM Chris Cranford <chris at hibernate.org> wrote:
>> Gunnar -
>> I don't particularly see a reason why we cannot as it seems we're
>> handling the CALLBACK mode with no BV provider present earlier in the
>> code path. I'm fine changing it.
>> On 02/04/2018 07:21 AM, Gunnar Morling wrote:
>> > Hi,
>> > If the JPA validation mode is set to CALLBACK, BV constraints such as
>> > @NotNull, @Size etc. are not reflected in the DDL created by ORM.
>> > Instead, in TypeSafeActivator, the BV constraints are only considered
>> > DDL if the validation mode is DDL or AUTO .
>> > CALLBACK is the safe way to ensure BV is invoked by JPA (instead of
>> > silently ignoring it if no BV provider is present), so it's the setting
>> > usually recommend. I think constraints should also be propagated to DDL
>> > this mode, so I'm wondering whether there a specific reason for the
>> > behaviour or wether we can change it?
>> > Thanks,
>> > --Gunnar
>> > 
>> > https://github.com/hibernate/hibernate-orm/blob/master/
>> > _______________________________________________
>> > hibernate-dev mailing list
>> > hibernate-dev at lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>> hibernate-dev mailing list
>> hibernate-dev at lists.jboss.org
More information about the hibernate-dev