'Can't map List<UUID> to database UUID[] Couldn't determine JDBCType for class java.util.UUID

I have following table definition:

CREATE TABLE my_table (
       id UUID NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
       result UUID []    
);

Entity definition:

@Table("my_table ")
public class MyTable {

    @Id
    private UUID id;
    
    private List<UUID> result;
    //get set
}

Repository:

@Repository
public interface MytableRepository extends PagingAndSortingRepository<MyTable, UUID> {
}

Start code:

@SpringBootApplication
@EnableJdbcAuditing
public class Main {

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(Main.class, args);

        MytableRepository mytableRepository = applicationContext.getBean(MytableRepository.class);
        MyTable myTable = new MyTable();
        myTable.setResult(Arrays.asList(UUID.randomUUID()));

        mytableRepository.save(myTable);
    }

Error is:

...
Caused by: java.lang.IllegalArgumentException: Couldn't determine JDBCType for class java.util.UUID
    at org.springframework.util.Assert.notNull(Assert.java:219)
    at org.springframework.data.jdbc.core.convert.DefaultJdbcTypeFactory.createArray(DefaultJdbcTypeFactory.java:72)
    at org.springframework.data.jdbc.core.convert.BasicJdbcConverter.writeJdbcValue(BasicJdbcConverter.java:306)
    at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.addConvertedValue(DefaultDataAccessStrategy.java:560)
    at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.addConvertedPropertyValue(DefaultDataAccessStrategy.java:548)
    at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.lambda$getParameterSource$2(DefaultDataAccessStrategy.java:462)
    at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:360)
    at org.springframework.data.mapping.PersistentEntity.doWithAll(PersistentEntity.java:255)
    at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.getParameterSource(DefaultDataAccessStrategy.java:440)
    at org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy.insert(DefaultDataAccessStrategy.java:112)
    at org.springframework.data.jdbc.core.JdbcAggregateChangeExecutionContext.executeInsertRoot(JdbcAggregateChangeExecutionContext.java:94)
    at org.springframework.data.jdbc.core.AggregateChangeExecutor.execute(AggregateChangeExecutor.java:66)
    ... 43 more

How can I fix it ?

P.S.

spring boot version is 2.6.2

plugins {
    id 'org.springframework.boot' version '2.6.2' apply false

P.S.2

I tried to do some changes:

 ...
 private List<String> result;
 ...


CREATE TABLE my_table (
       id UUID NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
       result varchar[]    
);

And it works properly but I would like to have array of UUID



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source