-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19829 - Deprecate MultiIdentifierLoadAccess and the Session.byMultipleIds() methods #11070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
0530f02
5c0b942
54c2d38
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate; | ||
|
||
|
||
import jakarta.persistence.EntityGraph; | ||
import jakarta.persistence.FindOption; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* When {@linkplain SessionChecking} is enabled, this option controls how | ||
* to handle entities which are already contained by the persistence context | ||
* but which are in a removed state (marked for removal, but not yet flushed). | ||
* <p> | ||
* The default is {@link #EXCLUDE}. | ||
* | ||
* @see org.hibernate.Session#findMultiple(Class, List, FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
* | ||
* @since 7.2 | ||
*/ | ||
public enum IncludeRemovals implements MultiFindOption { | ||
/** | ||
* Removed entities are included in the load result. | ||
*/ | ||
INCLUDE, | ||
/** | ||
* The default. Removed entities are excluded from the load result. | ||
* <p/> | ||
* When combined with {@linkplain OrderedReturn#UNORDERED}, the entity is | ||
* simply excluded from the result. | ||
* <p/> | ||
|
||
* When combined with {@linkplain OrderedReturn#ORDERED}, the entity is replaced | ||
* by {@code null} in the result. | ||
* | ||
* @see OrderedReturn | ||
*/ | ||
EXCLUDE | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate; | ||
|
||
|
||
import jakarta.persistence.EntityGraph; | ||
import jakarta.persistence.FindOption; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Simple marker interface for FindOptions which can be applied to multiple id loading. | ||
* | ||
* @see org.hibernate.Session#findMultiple(Class, List, FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
* | ||
* @since 7.2 | ||
*/ | ||
public interface MultiFindOption extends FindOption { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate; | ||
|
||
|
||
import jakarta.persistence.EntityGraph; | ||
import jakarta.persistence.FindOption; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Indicates whether the result list should be ordered relative to the | ||
* position of the identifier list. E.g. | ||
* <pre> | ||
* List<Person> results = session.findMultiple( | ||
* Person.class, | ||
* List.of(1,2,3,2), | ||
* ORDERED | ||
* ); | ||
* assert results.get(0).getId() == 1; | ||
* assert results.get(1).getId() == 2; | ||
* assert results.get(2).getId() == 3; | ||
* assert results.get(3).getId() == 2; | ||
* </pre> | ||
* <p> | ||
* The default is {@link #ORDERED}. | ||
* | ||
* @see org.hibernate.Session#findMultiple(Class, List, FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
* | ||
* @since 7.2 | ||
*/ | ||
public enum OrderedReturn implements MultiFindOption { | ||
/** | ||
* The default. The result list is ordered relative to the | ||
* position of the identifiers list. This may result in {@code null} | ||
* elements in the list - <ul> | ||
* <li>non-existent identifiers | ||
* <li>removed entities (when combined with {@linkplain IncludeRemovals#EXCLUDE}) | ||
* </ul> | ||
* <p/> | ||
* The result list will also always have the same length as the identifier list. | ||
* | ||
* @see IncludeRemovals | ||
*/ | ||
ORDERED, | ||
/** | ||
* The result list may be in any order. | ||
*/ | ||
UNORDERED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate; | ||
|
||
|
||
import jakarta.persistence.EntityGraph; | ||
import jakarta.persistence.FindOption; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Indicates whether the persistence context should be checked for entities | ||
* matching the identifiers to be loaded - <ul> | ||
* <li>Entities which are in a managed state are not re-loaded from the database. | ||
* <li>Entities which are in a removed state are {@linkplain IncludeRemovals#EXCLUDE excluded} | ||
* from the result by default, but can be {@linkplain IncludeRemovals#INCLUDE included} if desired. | ||
* </ul> | ||
* <p/> | ||
* The default is {@link #DISABLED} | ||
* | ||
* @see org.hibernate.Session#findMultiple(Class, List , FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
* | ||
* @since 7.2 | ||
*/ | ||
public enum SessionChecking implements MultiFindOption { | ||
/** | ||
* The persistence context will be checked. Identifiers for entities already contained | ||
* in the persistence context will not be sent to the database for loading. If the | ||
* entity is marked for removal in the persistence context, whether it is returned | ||
* is controlled by {@linkplain IncludeRemovals}. | ||
* | ||
* @see IncludeRemovals | ||
*/ | ||
ENABLED, | ||
/** | ||
* The default. All identifiers to be loaded will be read from the database and returned. | ||
*/ | ||
DISABLED | ||
} |
There was a problem hiding this comment.
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 ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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