quarkus: Result of native query cannot be casted to String, when working with MySQL

Describe the bug

If we use method createNativeQuery of class org.hibernate.reactive.mutiny.Mutiny.SessionFactory to run query against MySQL or MariaDB database and return the query’s result as String, we receive an error com.sun.proxy.$Proxy33 cannot be cast to class java.lang.String.

Expected behavior

We should be able to receive a result of a native query.

Actual behavior

The method throws an exception.

How to Reproduce?

Reproducer: https://github.com/fedinskiy/quarkus-test-suite/tree/reproducer/hibernate-mysql-string

Steps to reproduce:

  1. Run mvn clean verify -pl io.quarkus.ts.qe:hibernate-reactive -Dit.test=MySQLDatabaseIT#reproducer* OR
  2. Run mvn clean verify -pl io.quarkus.ts.qe:hibernate-reactive -Dit.test=MariaDbDatabaseIT#reproducer*

Method reproducerTitle, which accesses data like this: session.createNativeQuery("SELECT title FROM books WHERE id = " + id, String.class) fails. Method reproducerBook, which accesses data like this: session.createNativeQuery(""SELECT * FROM books WHERE id = " + id, Book.class) succeeds.

For comparison, if we replace MySQLDatabaseIT in the first step to Postgresql13DatabaseIT, MsSQLDatabaseIT or DB2DatabaseIT, which use exactly the same code, but connect to other databases( with corresponding drivers), both methods succeed.

Since there is no MariaDB-specific driver in Reactive Hibernate, both MySQLDatabaseIT and MariaDbDatabaseIT use the same parameters and drivers, but connect to different DBMS.

Output of uname -a or ver

OS name: “linux”, version: “5.15.6-100.fc34.x86_64”

Output of java -version

11.0.13, vendor: Eclipse Adoptium

GraalVM version (if different from Java)

No response

Quarkus version or git rev

4b4d655db69d527df39c3c00aff3281a36248760

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (16 by maintainers)

Most upvoted comments

Proper label is probably area/hibernate-reactive