-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-19829 - Deprecate MultiIdentifierLoadAccess and byMultipleIds #11061
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
Closed
+561
−177
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5937abd
HHH-19829 - Introduce MultiFindOptions and its implementations for us…
jrenaat e87b641
HHH-19829 - replicate some existing tests in MultiLoadTest to use fin…
jrenaat acceac6
HHH-19829 - Deprecate MultiIdentifierLoadAccess and the Session.byMul…
jrenaat 204da85
HHH-19829 - Restrict use of MultiFindOptions to the findMultiple oper…
jrenaat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
hibernate-core/src/main/java/org/hibernate/IncludeRemovals.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* MultiFindOption implementation to specify whether the returned list | ||
* of entity instances should contain instances that have been | ||
* {@linkplain Session#remove(Object) marked for removal} in the | ||
* current session, but not yet deleted in the database. | ||
* <p> | ||
* The default is {@link #EXCLUDE}, meaning that instances marked for | ||
* removal are replaced by null in the returned list of entities when {@link OrderedReturn} | ||
* is used. | ||
* | ||
* @see org.hibernate.MultiFindOption | ||
* @see OrderedReturn | ||
* @see org.hibernate.Session#findMultiple(Class, List, FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
*/ | ||
public enum IncludeRemovals implements MultiFindOption { | ||
INCLUDE, | ||
EXCLUDE | ||
} |
14 changes: 14 additions & 0 deletions
14
hibernate-core/src/main/java/org/hibernate/MultiFindOption.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright Red Hat Inc. and Hibernate Authors | ||
*/ | ||
package org.hibernate; | ||
|
||
|
||
import jakarta.persistence.FindOption; | ||
|
||
/** | ||
* Simple marker interface for FindOptions which can be applied to multiple id loading. | ||
*/ | ||
public interface MultiFindOption extends FindOption { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
hibernate-core/src/main/java/org/hibernate/OrderedReturn.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* MultiFindOption implementation to specify whether the returned list | ||
* of entity instances should be ordered, where the position of an entity | ||
* instance is determined by the position of its identifier | ||
* in the list of ids passed to {@code findMultiple(...)}. | ||
* <p> | ||
* The default is {@link #ORDERED}, meaning the positions of the entities | ||
* in the returned list correspond to the positions of their ids. In this case, | ||
* the {@link IncludeRemovals} handling of entities marked for removal | ||
* becomes important. | ||
* | ||
* @see org.hibernate.MultiFindOption | ||
* @see IncludeRemovals | ||
* @see org.hibernate.Session#findMultiple(Class, List, FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
*/ | ||
public enum OrderedReturn implements MultiFindOption { | ||
ORDERED, | ||
UNORDERED | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
hibernate-core/src/main/java/org/hibernate/SessionChecking.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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; | ||
|
||
/** | ||
* MultiFindOption implementation to specify whether the ids of managed entity instances already | ||
* cached in the current persistence context should be excluded. | ||
* from the list of ids sent to the database. | ||
* <p> | ||
* The default is {@link #DISABLED}, meaning all ids are included and sent to the database. | ||
* | ||
* Use {@link #ENABLED} to exclude already managed entity instance ids from | ||
* the list of ids sent to the database. | ||
* | ||
* @see org.hibernate.MultiFindOption | ||
* @see org.hibernate.Session#findMultiple(Class, List , FindOption...) | ||
* @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...) | ||
*/ | ||
public enum SessionChecking implements MultiFindOption { | ||
ENABLED, | ||
DISABLED | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One more thing, since
MultiFindOption
:MultiFindOption
)I would just remove it, and make these new options implement
FindOption
directly.It's not adding anything.
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.
It was steve's suggestion to do it like this.
It does make the restriction in
session.find(..., FindOption ... options)
somewhat cleaner having it aroundThere 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.
I don't know what you mean by this.
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.
is quite nicer than individually checking for each type.
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.
I disagree. Find usages of MultiFindOption has value.
Your opinion.
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.
Which is what I meant
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.
So if you really insist on retaining it (I would not, since this is the root package
org.hibernate
) then how aboutFindMultipleOption
, to reflect that it is an option for thefindMultiple()
method?