hibernate / hibernate-reactive

A reactive API for Hibernate ORM, supporting non-blocking database drivers and a reactive style of interaction with the database.
https://hibernate.org/reactive
Apache License 2.0
442 stars 92 forks source link

ReactiveDeferredResultSetAccess use ResultSetAccess interface default resolveType impl will cause NPE #1887

Open paomian opened 7 months ago

paomian commented 7 months ago

I'm using quarkus 3.9.3 with hibernate reactive. database is pg. When I call createNativeQuery and the query table result contains field which type is json will cause NPE. The reason I conducted a brief survey was

https://github.com/hibernate/hibernate-orm/blob/aae9b1e55d865d215070ee7d74ecc49593f83f4f/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/ResultSetAccess.java#L78-L99

columnTypeName is from this method. it must be null. https://github.com/hibernate/hibernate-reactive/blob/a8e757f772f84c59a8b21edf7a8f1d6469d11ea2/hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java#L1352-L1356

and then call resolveSqlTypeDescriptor in PostgreSQLDialect. when jdbcTypeCode is OTHER it will cause NPE because columnTypeName is null https://github.com/hibernate/hibernate-orm/blob/aae9b1e55d865d215070ee7d74ecc49593f83f4f/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java#L308-L337

DavideD commented 1 day ago

This issue has been solved as part of https://github.com/hibernate/hibernate-reactive/issues/1915