File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/thisalias Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .hibernate .orm .test .query .hql .thisalias ;
2+
3+ import jakarta .persistence .Basic ;
4+ import jakarta .persistence .Entity ;
5+ import jakarta .persistence .GeneratedValue ;
6+ import jakarta .persistence .Id ;
7+ import org .hibernate .testing .orm .junit .DomainModel ;
8+ import org .hibernate .testing .orm .junit .SessionFactory ;
9+ import org .hibernate .testing .orm .junit .SessionFactoryScope ;
10+ import org .junit .jupiter .api .Test ;
11+
12+ @ SessionFactory
13+ @ DomainModel (annotatedClasses = HQLThisTest .This .class )
14+ public class HQLThisTest {
15+ @ Test
16+ void test (SessionFactoryScope scope ) {
17+ scope .inTransaction (s -> s .persist (new This ("gavin" )));
18+ scope .inSession (s -> {
19+ s .createSelectionQuery ("select this.name from This this where this.name = 'gavin'" ).getSingleResult ();
20+ s .createSelectionQuery ("from This where this.name = 'gavin'" ).getSingleResult ();
21+ s .createSelectionQuery ("select this.name from This order by this.name" ).getSingleResult ();
22+ s .createSelectionQuery ("select count(this) from This" ).getSingleResult ();
23+ s .createSelectionQuery ("select id(this) from This" ).getSingleResult ();
24+ });
25+ }
26+ @ Entity
27+ static class This {
28+ @ Id @ GeneratedValue
29+ long id ;
30+ @ Basic (optional = false )
31+ String name ;
32+
33+ This (String gavin ) {}
34+ This () {}
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments