Skip to content

Commit

Permalink
HHH-18629 add test for issue
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
quaff committed Sep 18, 2024
1 parent fc2b1b9 commit 0684c6e
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ public void testNativeQueryWithPlaceholders(SessionFactoryScope scope) {
);
}

@Test
@JiraKey( "HHH-18629" )
public void testNativeQueryWithResultClassAndPlaceholders(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
NativeQuery<Book> query = session
.createNativeQuery(
"select {book.*} from BOOK_T book", Book.class );
query.addEntity( "book", Book.class );
List<Book> results = query.list();

assertEquals( 1, results.size() );
}
);
}

@Entity(name = "Book")
@IdClass(BookPK.class)
@Table(name = "BOOK_T")
Expand Down

0 comments on commit 0684c6e

Please sign in to comment.