4
4
*/
5
5
package org .hibernate .query .programmatic ;
6
6
7
+ import jakarta .persistence .EntityManager ;
7
8
import jakarta .persistence .criteria .CriteriaQuery ;
8
9
import jakarta .persistence .criteria .CriteriaBuilder ;
9
10
import jakarta .persistence .criteria .Root ;
10
11
import org .hibernate .Incubating ;
11
- import org .hibernate .SharedSessionContract ;
12
+ import org .hibernate .Session ;
13
+ import org .hibernate .StatelessSession ;
12
14
import org .hibernate .query .IllegalSelectQueryException ;
13
15
import org .hibernate .query .Order ;
14
16
import org .hibernate .query .SelectionQuery ;
@@ -63,7 +65,7 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
63
65
*
64
66
* @return {@code this} for method chaining.
65
67
*/
66
- SelectionSpecification <T > sort (Order <T > order );
68
+ SelectionSpecification <T > sort (Order <? super T > order );
67
69
68
70
/**
69
71
* Sets the ordering for this selection specification.
@@ -74,7 +76,7 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
74
76
*
75
77
* @return {@code this} for method chaining.
76
78
*/
77
- SelectionSpecification <T > resort (Order <T > order );
79
+ SelectionSpecification <T > resort (Order <? super T > order );
78
80
79
81
/**
80
82
* Sets the sorting for this selection specification.
@@ -85,13 +87,13 @@ public interface SelectionSpecification<T> extends QuerySpecification<T> {
85
87
*
86
88
* @return {@code this} for method chaining.
87
89
*/
88
- SelectionSpecification <T > resort (List <Order <T >> orders );
90
+ SelectionSpecification <T > resort (List <Order <? super T >> orders );
89
91
90
92
/**
91
93
* Covariant override.
92
94
*/
93
95
@ Override
94
- SelectionSpecification <T > restrict (Restriction <T > restriction );
96
+ SelectionSpecification <T > restrict (Restriction <? super T > restriction );
95
97
96
98
/**
97
99
* Add a fetch {@linkplain Path path} to the specification.
@@ -133,7 +135,7 @@ interface Augmentation<T> {
133
135
* SelectionSpecification.create(Book.class)
134
136
* .augment((builder, query, book) ->
135
137
* // eliminate explicit references to 'builder'
136
- * new CriteriaDefinition<> (query) {{
138
+ * new CriteriaDefinition<> (query) {{
137
139
* where(like(entity.get(BasicEntity_.title), titlePattern),
138
140
* greaterThan(book.get(Book_.pages), minPages));
139
141
* orderBy(asc(book.get(Book_.isbn)));
@@ -153,13 +155,22 @@ interface Augmentation<T> {
153
155
* Covariant override.
154
156
*/
155
157
@ Override
156
- SelectionQuery <T > createQuery (SharedSessionContract session );
158
+ SelectionQuery <T > createQuery (Session session );
159
+
160
+ /**
161
+ * Covariant override.
162
+ */
163
+ @ Override
164
+ SelectionQuery <T > createQuery (StatelessSession session );
165
+
166
+ @ Override
167
+ SelectionQuery <T > createQuery (EntityManager entityManager );
157
168
158
169
/**
159
170
* Returns a specification reference which can be used to programmatically,
160
171
* iteratively build a {@linkplain SelectionQuery} for the given entity type,
161
- * allowing the addition of {@linkplain SelectionSpecification #sort sorting}
162
- * and {@linkplain SelectionSpecification #restrict restrictions}.
172
+ * allowing the addition of {@linkplain #sort sorting}
173
+ * and {@linkplain #restrict restrictions}.
163
174
* This is effectively the same as calling {@linkplain #create(Class, String)}
164
175
* with {@code "from {rootEntityType}"} as the HQL.
165
176
*
@@ -175,8 +186,8 @@ static <T> SelectionSpecification<T> create(Class<T> rootEntityType) {
175
186
/**
176
187
* Returns a specification reference which can be used to programmatically,
177
188
* iteratively build a {@linkplain SelectionQuery} based on a base HQL statement,
178
- * allowing the addition of {@linkplain SelectionSpecification #sort sorting}
179
- * and {@linkplain SelectionSpecification #restrict restrictions}.
189
+ * allowing the addition of {@linkplain #sort sorting}
190
+ * and {@linkplain #restrict restrictions}.
180
191
*
181
192
* @param hql The base HQL query.
182
193
* @param resultType The result type which will ultimately be returned from the {@linkplain SelectionQuery}
@@ -194,8 +205,8 @@ static <T> SelectionSpecification<T> create(Class<T> resultType, String hql) {
194
205
/**
195
206
* Returns a specification reference which can be used to programmatically,
196
207
* iteratively build a {@linkplain SelectionQuery} for the given criteria query,
197
- * allowing the addition of {@linkplain SelectionSpecification #sort sorting}
198
- * and {@linkplain SelectionSpecification #restrict restrictions}.
208
+ * allowing the addition of {@linkplain #sort sorting}
209
+ * and {@linkplain #restrict restrictions}.
199
210
*
200
211
* @param criteria The criteria query
201
212
*
0 commit comments