[hibernate-dev] ORM DDL doesn't reflect BV constraints with validation mode CALLBACK

Sanne Grinovero sanne at hibernate.org
Tue Feb 6 10:42:54 EST 2018


On 6 February 2018 at 15:34, Steve Ebersole <steve at hibernate.org> wrote:
>
>
> On Tue, Feb 6, 2018 at 9:18 AM Sanne Grinovero <sanne at hibernate.org> wrote:
>>
>> On 6 February 2018 at 14:46, Steve Ebersole <steve at hibernate.org> wrote:
>> > I'm not sure I would call them separate. They are clearly linked. Look
>> > at
>> > it this way, if we export various "validation" constraints to the
>> > database
>> > (DDL) it is, practically speaking, a performance overhead to also
>> > perform
>> > those checks in memory. Right? This is, I think, the distinction you may
>> > be
>> > missing in terms of DDL as a separate mode - only do these checks once,
>> > at
>> > the database level.
>>
>> That's a grey area. Sure they are linked, as some combinations would
>> be nonsense, but I'd see benefits as well in being able to control
>> such aspects better.
>>
>> In terms of performance, it might be beneficial to abort an operation
>> early on ("in memory") rather than have to bother the database. It's
>> far easier to scale a system by adding more JVMs than to scale the
>> RDBMs.
>>
>> True it might be redundant if the business logic is perfect, but then
>> you'd not need validation.
>
>
> We tend to do this argument where it "not what we would do".  Well not
> everyone is us :)

Not understanding what you mean with that. I'm well aware others might
have other opinions, in fact I'm suggesting to allow people more
control than what you established should be right?

> Also you are arguing about optimizing the exception case.  The majority case
> is that the in-memory validations will (a) happen and (b) pass and then we
> still have the db validations happening.

I'm aware. And that's why I said "it might be redundant ... but then
you'd not need validation".
Obviously everyone needs validation, so optimising the exception case
might be important - especially since like I said it's much cheaper to
do so in in local memory rather than have a round trip to the RDBMS to
figure it out, and consume precious RBDMS resources to have it do the
same job.

>> > Can all such validations be handled at the database level via
>> > contraints?
>> > No of course not - but the vast majority in fact can.
>>
>> Back in the days I've found it very useful that Hibernate ORM +
>> Validator + custom naming strategies, etc.. would allow me to fully
>> control all details of the DDL.
>> I used to version the DDL and have a script which gets ORM to dump it
>> on the same resource for each change on the model, to immediately see
>> the diff and understand all implications of any change on the model.
>> Ideal also for beginners to grow confidence in what exactly all those
>> annotations will do..
>
> Neither what Gunnar is saying nor what we do not preclude that.

Ok good to know. I remember some years back it wasn't doing what I'd
like - I don't remember what exactly now, but I remember wishing it
allowed the user more control.

Thanks,
Sanne


More information about the hibernate-dev mailing list