hibernate-reactive: java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because the return value of "io.vertx.sqlclient.RowSet.columnsNames()" is null
import jakarta.persistence.EntityManagerFactory;
import org.hibernate.reactive.mutiny.Mutiny;
@Inject
EntityManagerFactory emf;
public Uni<Integer> myFunc() {
Mutiny.SessionFactory factory = emf.unwrap(Mutiny.SessionFactory.class);
return factory.withSession(session -> { session.createNativeQuery(storedProcedureCall).getSingleResultOrNull()
}
The call errors out when the stored procedure does not return any result with
java.lang.NullPointerException: Cannot invoke “java.util.List.size()” because the return value of “io.vertx.sqlclient.RowSet.columnsNames()” is null
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 21 (20 by maintainers)
Commits related to this issue
- [#1792] Add null checks in ResultSetAdaptor When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNames` w... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add null checks in ResultSetAdaptor When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNames` w... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add new HibernateException for when there are no results It should get thrown when a user call `.getSingleResultOrNull()` but the SQL query doesn't return any result. For example, when creati... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Throw an exception if there is no result When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNam... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull and getSingleResult We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add new HibernateException for when there are no results It should get thrown when a user call `.getSingleResultOrNull()` but the SQL query doesn't return any result. For example, when creati... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Throw an exception if there is no result When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNam... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull and getSingleResult We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add new HibernateException for when there are no results It should get thrown when a user call `.getSingleResultOrNull()` but the SQL query doesn't return any result. For example, when creati... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Throw an exception if there is no result When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNam... — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull and getSingleResult We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to DavideD/hibernate-reactive by DavideD 7 months ago
- [#1792] Add new HibernateException for when there are no results It should get thrown when a user call `.getSingleResultOrNull()` but the SQL query doesn't return any result. For example, when creati... — committed to hibernate/hibernate-reactive by DavideD 7 months ago
- [#1792] Throw an exception if there is no result When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNam... — committed to hibernate/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull and getSingleResult We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to hibernate/hibernate-reactive by DavideD 7 months ago
- [#1792] Add new HibernateException for when there are no results It should get thrown when a user call `.getSingleResultOrNull()` but the SQL query doesn't return any result. For example, when creati... — committed to hibernate/hibernate-reactive by DavideD 7 months ago
- [#1792] Throw an exception if there is no result When running a native query that doesn't return any result (for example, the creation of a stored procedure), `io.vertx.sqlclient.SqlResult#columnsNam... — committed to hibernate/hibernate-reactive by DavideD 7 months ago
- [#1792] Add test for getSingleResultOrNull and getSingleResult We are checking that it doesn't throw a NullPointerException if the result of the query doesn't have any columns names. — committed to hibernate/hibernate-reactive by DavideD 7 months ago
😃 I don’t think anybody is suggesting to keep the NPE
Whatever the case, it’s still unacceptable that we throw an NPE. If this was caused by illegal usage of the API, we need a better exception.
This is a native queries, I don’t think entities matter that much. But it would help to know which database you are using and what the SQL you are passing looks like (what’s the value of
storedProcedureCall?).At the moment, we only test stored procedures for PostgreSQL:
I suspect we will probably need a null-check anyway