File tree Expand file tree Collapse file tree 3 files changed +11
-10
lines changed
main/java/org/hibernate/tool/orm/jbt
test/java/org/hibernate/tool/orm/jbt/api/wrp Expand file tree Collapse file tree 3 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1
1
package org .hibernate .tool .orm .jbt .api .wrp ;
2
2
3
- import jakarta .persistence .Query ;
4
-
5
3
public interface SessionWrapper extends Wrapper {
6
4
7
5
String getEntityName (Object o ) ;
@@ -10,6 +8,6 @@ public interface SessionWrapper extends Wrapper {
10
8
boolean isOpen ();
11
9
void close ();
12
10
boolean contains (Object o );
13
- Query createCriteria (Class <?> c );
11
+ QueryWrapper createCriteria (Class <?> c );
14
12
15
13
}
Original file line number Diff line number Diff line change 2
2
3
3
import org .hibernate .Session ;
4
4
import org .hibernate .SessionFactory ;
5
+ import org .hibernate .query .Query ;
5
6
import org .hibernate .tool .orm .jbt .api .wrp .QueryWrapper ;
6
7
import org .hibernate .tool .orm .jbt .api .wrp .SessionFactoryWrapper ;
7
8
import org .hibernate .tool .orm .jbt .api .wrp .SessionWrapper ;
8
9
9
- import jakarta .persistence .Query ;
10
10
import jakarta .persistence .criteria .CriteriaBuilder ;
11
11
import jakarta .persistence .criteria .CriteriaQuery ;
12
12
import jakarta .persistence .criteria .Root ;
@@ -72,12 +72,12 @@ public boolean contains(Object o) {
72
72
}
73
73
74
74
@ Override
75
- public Query createCriteria (Class <?> c ) {
75
+ public QueryWrapper createCriteria (Class <?> c ) {
76
76
CriteriaBuilder criteriaBuilder = session .getCriteriaBuilder ();
77
77
CriteriaQuery <?> criteriaQuery = criteriaBuilder .createQuery (c );
78
- Root root = criteriaQuery .from (c );
79
- criteriaQuery . select ( root );
80
- return (( Session ) getWrappedObject ()). createQuery ( criteriaQuery );
78
+ criteriaQuery . select (( Root ) criteriaQuery .from (c ) );
79
+ Query <?> query = (( Session ) getWrappedObject ()). createQuery ( criteriaQuery );
80
+ return QueryWrapperFactory . createQueryWrapper ( query );
81
81
}
82
82
83
83
}
Original file line number Diff line number Diff line change 16
16
import org .hibernate .SessionFactory ;
17
17
import org .hibernate .cfg .AvailableSettings ;
18
18
import org .hibernate .cfg .Configuration ;
19
+ import org .hibernate .query .Query ;
19
20
import org .hibernate .tool .orm .jbt .internal .factory .SessionWrapperFactory ;
20
21
import org .hibernate .tool .orm .jbt .util .MockConnectionProvider ;
21
22
import org .hibernate .tool .orm .jbt .util .MockDialect ;
@@ -126,8 +127,10 @@ public void testContains() {
126
127
127
128
@ Test
128
129
public void testCreateCriteria () {
129
- jakarta .persistence .Query query = sessionWrapper .createCriteria (Foo .class );
130
- assertNotNull (query );
130
+ QueryWrapper queryWrapper = sessionWrapper .createCriteria (Foo .class );
131
+ assertNotNull (queryWrapper );
132
+ Query <?> q = (Query )queryWrapper .getWrappedObject ();
133
+ assertSame (q .getSession (), sessionWrapper .getWrappedObject ());
131
134
}
132
135
133
136
}
You can’t perform that action at this time.
0 commit comments