Skip to content

Commit 02e053c

Browse files
committed
additional test for implicit instantiation with native SQL
1 parent c01d391 commit 02e053c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/ImplicitInstantiationTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)