Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres UUID array mapping #731

Open
IvoMajic opened this issue Aug 23, 2020 · 0 comments
Open

Postgres UUID array mapping #731

IvoMajic opened this issue Aug 23, 2020 · 0 comments

Comments

@IvoMajic
Copy link

IvoMajic commented Aug 23, 2020

I have a Postgres column with a UUID array, in the class

ResultSetGetterFactory {

        factoryRegistry.put(UUID.class, new GetterFactory<ResultSet, JdbcColumnKey>() { ... }

}

the column type is mapped to JdbcColumnKey.UNDEFINED_TYPE, so the deserialization fails as the type is already a UUID object and UUIDUnspecifiedTypeGetter does not have that option in its switch case.

Interestingly in the same file below, we have this:

case Types.OTHER:
        // assume it's a UUID postgres
        return (Getter<ResultSet, P>) new ObjectResultSetGetter(key.getIndex());

But the JDBCColumn was never mapped to Types.OTHER

The exception:

java.lang.IllegalArgumentException: Cannot convert 79384f39-42f3-4dd8-995d-8580d59d72e2 to UUID
at org.simpleflatmapper.reflect.getter.UUIDUnspecifiedTypeGetter.get(UUIDUnspecifiedTypeGetter.java:29)

In my record class it properly marked as

    public void setImages(UUID[] value) {
        set(8, value);
    }

    public UUID[] getImages() {
        return (UUID[]) get(8);
    }

For now, I managed to work around it by adding a custom column property like this to the mapper (Kotlin syntax)

addColumnProperty(
        Predicate { columnKey: JdbcColumnKey ->
                columnKey.name == "images"
        },
        SqlTypeColumnProperty.of(Types.OTHER)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant