Skip to content

Conversation

sebersole
Copy link
Member

@sebersole sebersole commented Oct 6, 2025

HHH-19829 - Deprecate MultiIdentifierLoadAccess and the Session.byMultipleIds() methods


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-19829

@sebersole
Copy link
Member Author

Follow-up on #11061

* `ReadOnlyMode` - whether the entities loaded should be marked as read-only.
* `LockMode` (`LockModeType`) - a lock mode to be applied
* `Timeout` - if a pessimistic lock mode is used, a timeout to allow
* `Locking.Scope` (PessimisticLockScope`) - if a pessimistic lock mode is used, what scope should it be applied
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what scope should it be applied to ?

Copy link
Member Author

@sebersole sebersole Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire section needs a re-write. Feel free to tackle it :)

I'm just trying to improve it by removing out dated information - addition by subtraction.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I was just indicating that perhaps the 'to' was missing, that's all

Comment on lines +31 to +36
List<Person> persons = session.findMultiple(
Person.class,
List.of(1,2,3),
PESSIMISTIC_WRITE,
ORDERED
);

Check notice

Code scanning / CodeQL

Unread local variable Note test

Variable 'List persons' is never read.
* <p/>
* When combined with {@linkplain OrderedReturn#UNORDERED}, the entity is
* simply excluded from the result.
* <p/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I keep tripping over this.
If by "excluded from the load result" you mean that no nulls are present in the load result for removed instances when sessionchecking == enabled, includeremovals == exclude and ordering == unordered, then I can't get this one to work as expected:
e.g. running MultiLoadTest.testUnorderedMultiLoadFrom2ndLevelCachePendingDeleteReturnRemoved, with these settings returns a List of size 3, where one element is null, which seems to contradict what follows the IF above.
If what follows the IF above is NOT what you meant then my assumption is wrong.

Copy link
Member Author

@sebersole sebersole Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think EXCLUDE + UNORDERED is really the only thing confusing you?

My memory is just wrong for that case. It does appear that in this case the null for the removed entity is still included in the result. That's not what I remember and I have no reasonable explanation why that is the case. I mean, I can see maybe wanting to avoid needing to resize the list later or something like that, but from a user perspective I think that seems wrong.

Given that, I almost think the naming is wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think EXCLUDE + UNORDERED is really the only thing confusing you?

this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My memory is just wrong for that case. It does appear that in this case the null for the removed entity is still included in the result. That's not what I remember and I have no reasonable explanation why that is the case. I mean, I can see maybe wanting to avoid needing to resize the list later or something like that, but from a user perspective I think that seems wrong.

Given that, I almost think the naming is wrong.

So, change name, reword doc some more, or create a jira if you consider it's a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not that I consider it a bug per-se. I just consider it less than obvious behavior. But I assume its probably always been this way. Perhaps a third option makes sense, though this third option would depend on the value for OrderedReturn.

enum IncludeRemovals {
    /** Legacy false option */
    INCLUDE,
    /** Legacy true option - replace with null */
    REPLACE,
    /** New option. */
    EXCLUDE
}

This new option would trigger the more (imo) appropriate behavior -

  • With ordered results, we replace with nulls. This is ofc needed to maintain ordering.
  • With unordered results, we'd not have any entry in the result for removed entities.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a backward compatibility problem with that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With adding a new option? Why would that be a problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misinterpreted the reformulated options, my bad

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.

2 participants