Skip to content

Commit 0684c6e

Browse files
committed
HHH-18629 add test for issue
wrong fileid’s alias fileid1_0_0_ is used instead of fileid1_0_1_ while transforming ResultSet to Book. ``` Column "fileid1_0_0_" not found [42122-224] org.h2.jdbc.JdbcSQLSyntaxErrorException: Column "fileid1_0_0_" not found [42122-224] at org.h2.message.DbException.getJdbcSQLException(DbException.java:514) at org.h2.message.DbException.getJdbcSQLException(DbException.java:489) at org.h2.message.DbException.get(DbException.java:223) at org.h2.message.DbException.get(DbException.java:199) at org.h2.jdbc.JdbcResultSet.getColumnIndex(JdbcResultSet.java:3492) at org.h2.jdbc.JdbcResultSet.findColumn(JdbcResultSet.java:178) at org.hibernate.sql.results.jdbc.internal.AbstractResultSetAccess.resolveColumnPosition(AbstractResultSetAccess.java:63) ```
1 parent fc2b1b9 commit 0684c6e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/query/sql/ClassIdNativeQueryTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ public void testNativeQueryWithPlaceholders(SessionFactoryScope scope) {
7979
);
8080
}
8181

82+
@Test
83+
@JiraKey( "HHH-18629" )
84+
public void testNativeQueryWithResultClassAndPlaceholders(SessionFactoryScope scope) {
85+
scope.inTransaction(
86+
session -> {
87+
NativeQuery<Book> query = session
88+
.createNativeQuery(
89+
"select {book.*} from BOOK_T book", Book.class );
90+
query.addEntity( "book", Book.class );
91+
List<Book> results = query.list();
92+
93+
assertEquals( 1, results.size() );
94+
}
95+
);
96+
}
97+
8298
@Entity(name = "Book")
8399
@IdClass(BookPK.class)
84100
@Table(name = "BOOK_T")

0 commit comments

Comments
 (0)