pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
5+ messages / 3 participants
[nested] [flat]
* [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
@ 2026-02-16 01:16 "fishloa (@fishloa)" <[email protected]>
0 siblings, 0 replies; 5+ messages in thread
From: fishloa (@fishloa) @ 2026-02-16 01:16 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
## 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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
@ 2026-02-16 11:04 ` "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2026-02-16 11:04 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
Well that's interesting.
I wonder what the implications of changing it to boolean would be?
@vlsi ?
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
@ 2026-02-16 11:17 ` "vlsi (@vlsi)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: vlsi (@vlsi) @ 2026-02-16 11:17 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
If GraalVM misbehaves, I would double check the reason for the failure before changing anything in pgjdbc.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
@ 2026-02-16 11:22 ` "davecramer (@davecramer)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: davecramer (@davecramer) @ 2026-02-16 11:22 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
apparently because ```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.``` but I'm still curious why we return a bit.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image
@ 2026-02-16 11:34 ` "vlsi (@vlsi)" <[email protected]>
3 siblings, 0 replies; 5+ messages in thread
From: vlsi (@vlsi) @ 2026-02-16 11:34 UTC (permalink / raw)
To: pgjdbc/pgjdbc <[email protected]>
AFAIK GraalVM should **keep** the semantics of the program, so I don't think it should make code paths unreachable arbitrarily
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-02-16 11:34 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-02-16 01:16 [pgjdbc/pgjdbc] issue #3940: BOOLEAN columns return Integer instead of Boolean in GraalVM native image "fishloa (@fishloa)" <[email protected]>
2026-02-16 11:04 ` "davecramer (@davecramer)" <[email protected]>
2026-02-16 11:17 ` "vlsi (@vlsi)" <[email protected]>
2026-02-16 11:22 ` "davecramer (@davecramer)" <[email protected]>
2026-02-16 11:34 ` "vlsi (@vlsi)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox