postgresqlquarkusjsonbresteasygraalvm

How to return null values from quarkus native built application?


I have a PostgreSQL database with columns that can contain null values. If I use quarkus dev mode or jvm, the query returns (correctly) null values. However, if I build with the native profile using GraalVM, it returns 0 for Integer and 0.0 for Float (instead of null).

I am using the quarkus-resteasy-jsonb extension and the following image during my multistage docker build: FROM quay.io/quarkus/ubi-quarkus-mandrel-builder-image:22.3-java17 AS build ...

What has already been tested:

Could be related to this: Quarkus numeric type (Integer, Float) return 0 instead of null

Here is the beginning of my entity class:

@Entity
@Table(name = DBUtils.MY_TABLE_NAME, schema = DBUtils.SCHEMA_NAME)
@Getter
@Setter
public class MyClass extends PanacheEntityBase {

private static Logger technicalLogger = Logger.getLogger(LoggerNames.TECHNICAL.getName());

@Id
@GeneratedValue(generator = "myclassSequenceGenerator")
@SequenceGenerator(name = "myclassSequenceGenerator", sequenceName  = "myclass_id_seq", allocationSize = 1)

@Column(name = "myclass_id", nullable = false)
public int myclassId;

@Column(name = "myclass_name", length = 50)
public String myclassName;

@Column(name = "street_length_m", length = 5)
public Integer lengthInMeters;  // <= gives 0 if null in DB

@Column(name = "street_length_km", length = 5)
public Float lengthInKilometers; // <= gives 0.0 if null in DB 
...

Any help would be highly appreciated. Many thanks in advance!


Solution

  • With the same configuration, Jackson instead of Jsonb, with GraalVM with Java21, this error is not hapenning.

    If you are using Active Record strategy, Lombok is not needed.

    There are an issue opened https://github.com/oracle/graal/issues/5672

    I would try: