File tree Expand file tree Collapse file tree 5 files changed +116
-0
lines changed
hibernate-core/src/main/java/org/hibernate Expand file tree Collapse file tree 5 files changed +116
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Copyright Red Hat Inc. and Hibernate Authors
4
+ */
5
+ package org .hibernate ;
6
+
7
+
8
+ import jakarta .persistence .EntityGraph ;
9
+ import jakarta .persistence .FindOption ;
10
+
11
+ import java .util .List ;
12
+
13
+ /**
14
+ * MultiFindOption implementation to specify whether the returned list
15
+ * of entity instances should contain instances that have been
16
+ * {@linkplain Session#remove(Object) marked for removal} in the
17
+ * current session, but not yet deleted in the database.
18
+ * <p>
19
+ * The default is {@link #EXCLUDE}, meaning that instances marked for
20
+ * removal are replaced by null in the returned list of entities when {@link OrderedReturn}
21
+ * is used.
22
+ *
23
+ * @see org.hibernate.MultiFindOption
24
+ * @see OrderedReturn
25
+ * @see org.hibernate.Session#findMultiple(Class, List, FindOption...)
26
+ * @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...)
27
+ */
28
+ public record IncludeRemovals (boolean include ) implements MultiFindOption {
29
+ public static IncludeRemovals INCLUDE = new IncludeRemovals ( true );
30
+ public static IncludeRemovals EXCLUDE = new IncludeRemovals ( false );
31
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Copyright Red Hat Inc. and Hibernate Authors
4
+ */
5
+ package org .hibernate ;
6
+
7
+
8
+ import jakarta .persistence .FindOption ;
9
+
10
+ /**
11
+ * Simple marker interface for FindOptions which can be applied to multiple id loading.
12
+ */
13
+ interface MultiFindOption extends FindOption {
14
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Copyright Red Hat Inc. and Hibernate Authors
4
+ */
5
+ package org .hibernate ;
6
+
7
+
8
+ import jakarta .persistence .EntityGraph ;
9
+ import jakarta .persistence .FindOption ;
10
+
11
+ import java .util .List ;
12
+
13
+ /**
14
+ * MultiFindOption implementation to specify whether the returned list
15
+ * of entity instances should be ordered, where the position of an entity
16
+ * instance is determined by the position of its identifier
17
+ * in the list of ids passed to {@code findMultiple(...)}.
18
+ * <p>
19
+ * The default is {@link #ORDERED}, meaning the positions of the entities
20
+ * in the returned list correspond to the positions of their ids. In this case,
21
+ * the {@link IncludeRemovals} handling of entities marked for removal
22
+ * becomes important.
23
+ *
24
+ * @see org.hibernate.MultiFindOption
25
+ * @see IncludeRemovals
26
+ * @see org.hibernate.Session#findMultiple(Class, List, FindOption...)
27
+ * @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...)
28
+ */
29
+ public record OrderedReturn (boolean ordered ) implements MultiFindOption {
30
+ public static OrderedReturn ORDERED = new OrderedReturn ( true );
31
+ public static OrderedReturn UNORDERED = new OrderedReturn ( false );
32
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ * Copyright Red Hat Inc. and Hibernate Authors
4
+ */
5
+ package org .hibernate ;
6
+
7
+
8
+ import jakarta .persistence .EntityGraph ;
9
+ import jakarta .persistence .FindOption ;
10
+
11
+ import java .util .List ;
12
+
13
+ /**
14
+ * MultiFindOption implementation to specify whether the ids of managed entity instances already
15
+ * cached in the current persistence context should be excluded.
16
+ * from the list of ids sent to the database.
17
+ * <p>
18
+ * The default is {@link #DISABLED}, meaning all ids are included and sent to the database.
19
+ *
20
+ * Use {@link #ENABLED} to exclude already managed entity instance ids from
21
+ * the list of ids sent to the database.
22
+ *
23
+ * @see org.hibernate.MultiFindOption
24
+ * @see org.hibernate.Session#findMultiple(Class, List , FindOption...)
25
+ * @see org.hibernate.Session#findMultiple(EntityGraph, List , FindOption...)
26
+ */
27
+ public record SessionChecking (boolean enabled ) implements MultiFindOption {
28
+ public static SessionChecking ENABLED = new SessionChecking ( true );
29
+ public static SessionChecking DISABLED = new SessionChecking ( false );
30
+ }
Original file line number Diff line number Diff line change @@ -960,6 +960,15 @@ else if ( option instanceof ReadOnlyMode ) {
960
960
else if ( option instanceof BatchSize batchSizeOption ) {
961
961
batchSize = batchSizeOption .batchSize ();
962
962
}
963
+ else if ( option instanceof SessionChecking sessionChecking ) {
964
+ loadAccess .enableSessionCheck ( sessionChecking .enabled () );
965
+ }
966
+ else if ( option instanceof OrderedReturn orderedReturn ) {
967
+ loadAccess .enableOrderedReturn ( orderedReturn .ordered () );
968
+ }
969
+ else if ( option instanceof IncludeRemovals includeRemovals ) {
970
+ loadAccess .enableReturnOfDeletedEntities ( includeRemovals .include () );
971
+ }
963
972
}
964
973
loadAccess .with ( lockOptions )
965
974
.with ( interpretCacheMode ( storeMode , retrieveMode ) )
You can’t perform that action at this time.
0 commit comments