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

Most upvoted comments

Here, in Reactive, an NPE is quite terrible. So we need to do something better, I’m just not sure what.

😃 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