File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
hibernate-core/src/test/java/org/hibernate/orm/test/query/hql Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public void testRecordInstantiationWithoutAlias(SessionFactoryScope scope) {
5555 }
5656
5757 @ Test
58- public void testSqlRecordInstantiationWithoutAlias (SessionFactoryScope scope ) {
58+ public void testSqlRecordInstantiationWithoutMapping (SessionFactoryScope scope ) {
5959 scope .inTransaction (
6060 session -> {
6161 session .persist (new Thing (1L , "thing" ));
@@ -69,6 +69,23 @@ public void testSqlRecordInstantiationWithoutAlias(SessionFactoryScope scope) {
6969 );
7070 }
7171
72+ @ Test
73+ public void testSqlRecordInstantiationWithMapping (SessionFactoryScope scope ) {
74+ scope .inTransaction (
75+ session -> {
76+ session .persist (new Thing (1L , "thing" ));
77+ Record result = (Record ) session .createNativeQuery ( "select id, upper(name) as name from thingy_table" , Record .class )
78+ .addScalar ("id" , Long .class )
79+ .addScalar ("name" , String .class )
80+ .addSynchronizedEntityClass (Thing .class )
81+ .getSingleResult ();
82+ assertEquals ( result .id (), 1L );
83+ assertEquals ( result .name (), "THING" );
84+ session .getTransaction ().setRollbackOnly ();
85+ }
86+ );
87+ }
88+
7289 @ Test
7390 public void testTupleInstantiationWithAlias (SessionFactoryScope scope ) {
7491 scope .inTransaction (
You can’t perform that action at this time.
0 commit comments