hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-19555 tests and doc

Open gavinking opened this issue 6 months ago • 8 comments

@SQLRestriction on a @ManyToOne @JoinTable is currently mostly-working, by accident.

This PR documents this possibility, and adds tests for it.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion. For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19555

gavinking avatar Jun 21 '25 09:06 gavinking

Fails on databases with merge emulation due to this condition in OptionalTableUpdateOperation:

if ( valuesAnalysis.getTablesWithPreviousNonNullValues().contains( tableMapping ) ) {

gavinking avatar Jun 21 '25 10:06 gavinking

@gavinking rebased the upsert impls for edb and hsql, and disabled the test for sybase. All tests green now. Over to you :+1:

jrenaat avatar Jul 07 '25 16:07 jrenaat

Nice! Thanks man!

We need to think what to do about Sybase (i.e. produce an error at startup or whatever, not quite sure.)

gavinking avatar Jul 07 '25 17:07 gavinking

Nice! Thanks man!

We need to think what to do about Sybase (i.e. produce an error at startup or whatever, not quite sure.)

Add an supportsSqlRestrictionOnJoinTableManyToOne by default true except for Sybase dialects in Dialect ?

jrenaat avatar Jul 08 '25 16:07 jrenaat

Nice! Thanks man! We need to think what to do about Sybase (i.e. produce an error at startup or whatever, not quite sure.)

Add an supportsSqlRestrictionOnJoinTableManyToOne by default true except for Sybase dialects in Dialect ?

Maybe rather supportsUpsert (or whatever it's named, it probably exists) + an error message stating that it's only supported on database with upsert support?

WDYT @gavinking?

yrodiere avatar Oct 06 '25 11:10 yrodiere

There's a comment on the issue:

I have found a second problem with this. All is well as long as such an association is fetched eagerly using a join. But for LAZY fetching, the restriction is never applied. So I would need @mbellade to help us repurpose the stuff done for @ConcreteProxy to add an extra “look-ahead” join with the restriction. I attempted to make this work myself, but I failed.

I'm not sure that this problem has been addressed yet. I'm guessing not. I don't think we can merge this until that part of it is done.

gavinking avatar Oct 07 '25 06:10 gavinking

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

Alright, so, based on my testing, we have two options here:

  1. disable this functionality for the two cases where we know it's currently broken:
    • fetch=LAZY, and
    • Sybase
  2. disable on Sybase, and fix the problem with lazy fetching by repurposing the @ConcreteProxy-style lookahead.

Apparently I tried to do 2 when I first looked at this, and couldn't figure it out, so we would need Marco's help on it.

Anyway, I have added tests.

gavinking avatar Oct 07 '25 07:10 gavinking