pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: fishloa (@fishloa) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
Date: Mon, 16 Feb 2026 01:16:33 +0000
Message-ID: <[email protected]> (raw)

## Description

When running in a GraalVM native image, `ResultSet.getObject()` for a PostgreSQL `BOOLEAN` column returns `java.lang.Integer` instead of `java.lang.Boolean`. This works correctly on the JVM.

## Environment

- **pgjdbc**: 42.7.9 (managed by Spring Boot 4.0.2)
- **GraalVM**: 25.0.2 (JDK 25)
- **PostgreSQL**: 18
- **Spring Data JDBC**: 4.0.2 (reads columns via reflection)

## Schema

```sql
CREATE TABLE user_emails (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL,
    email VARCHAR NOT NULL UNIQUE,
    is_primary BOOLEAN NOT NULL DEFAULT false,
    created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
```

## Entity

```java
@Table("user_emails")
public class UserEmail {
    @Id private UUID id;
    @Column("is_primary") private boolean primary;
    // ...
}
```

## Error (native image only, works fine on JVM)

```
java.lang.IllegalArgumentException: Can not set boolean field
    place.icomb.horti.entity.UserEmail.primary to java.lang.Integer
```

## Root cause

pgjdbc reports PostgreSQL `BOOLEAN` as JDBC type `Types.BIT` rather than `Types.BOOLEAN`. On the JVM, the internal type-conversion codepaths in `ResultSet.getObject()` still return `java.lang.Boolean` for `BIT(1)`. In a GraalVM native image, those conversion paths appear to be unreachable (or the reflection metadata is missing), so the raw `Integer` (0/1) is returned instead.

## Workaround

Register a Spring Data JDBC reading converter:

```java
@ReadingConverter
static class IntegerToBooleanConverter implements Converter<Integer, Boolean> {
    @Override
    public Boolean convert(Integer source) {
        return source != null && source != 0;
    }
}
```

## Expected behavior

`ResultSet.getObject()` for a `BOOLEAN` column should return `java.lang.Boolean` in both JVM and native image contexts. Ideally pgjdbc would also report `Types.BOOLEAN` instead of `Types.BIT` for PostgreSQL `boolean` columns.

view thread (5+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox