Skip to content

Conversation

gavinking
Copy link
Member

@gavinking gavinking commented Jun 21, 2025

@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
Copy link
Member Author

gavinking commented Jun 21, 2025

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

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

@jrenaat
Copy link
Member

jrenaat commented Jul 7, 2025

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

@gavinking
Copy link
Member Author

Nice! Thanks man!

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

@jrenaat
Copy link
Member

jrenaat commented Jul 8, 2025

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 ?

@yrodiere
Copy link
Member

yrodiere commented Oct 6, 2025

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?

@gavinking
Copy link
Member Author

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.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Oct 7, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@gavinking
Copy link
Member Author

gavinking commented Oct 7, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants