简体   繁体   中英

Using AttributeConverter converting to UUID results in 'No Dialect mapping for JDBC type' exception

So I have a class, lets say Dog (not an entity) containing only an UUID field. I then have the following AttributeConverter :

@Converter
public class DogConverter implements AttributeConverter<Dog, UUID> {
    @Override
    public UUID convertToDatabaseColumn(final Dog attribute) {
        return attribute.getUuid();
    }

    @Override
    public Dog convertToEntityAttribute(final UUID dbData) {
        return new Dog(dbData);
    }
}

I then use the Dog as a field in an entity class DogHouse :

@Entity
class DogHouse {
    ...
    @Convert(converter = DogConverter.class)
    private Dog dog;
    ...
}

Then I use liquibase to create a diff changelog against an empty postgresql database which then results in the following exception:

org.hibernate.MappingException: No Dialect mapping for JDBC type: 206384196

When I change to DogConverter to convert between a Dog and a String by also mapping the UUID to a string, liquibase works fine and no exception shows up.

Does anyone have any idea why the exception occurs and how to fix it?

I have the same issue with postgis Geometry and concluded that types supported by converter are limited compared to the ones supported by entity fields. In this post https://gitter.im/hibernate/hibernate-orm?at=5ab11305e4d1c636041f1251 if you search for "dialect" you see a similar questions. Answer seems to be it's not possible with Hibernate 5.2. Maybe it will be possible with Hibernate 6.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM