Anton Kolb
Anton Kolb

Reputation: 1

ClassCast exception class org.hibernate.type.CustomType cannot be cast to class org.hibernate.type.BasicPluralType

I've faced with a problem in one of my projects - created local db from dump file (Postgre 13), some columns were defined like varchar[] and interval.

CREATE TABLE public.table (
    id integer DEFAULT 1 NOT NULL,
    column_name character varying[]
);
CREATE TABLE public.table_2_name (
    id uuid NOT NULL,
    another_column_name interval NOT NULL
);

Fields for entities from these tables are defined like:

    @Type(ListArrayType.class)
    @Column(name = "COLUMN_NAME", columnDefinition = "varchar[]")
    private List<String> columnName;
    @Column(name = "ANOTHER_COLUMN_NAME")
    private Duration anotherColumnName;

But during startup I receive this error from Hibernate:

Schema-validation: wrong column type encountered in column [column_name] in table [table_name]; found [_varchar (Types#ARRAY)], but expecting [varchar[] (Types#OTHER)]

The same appears with:

Schema-validation: wrong column type encountered in column [another_column_name] in table [table_2_name]; found [interval (Types#OTHER)], but expecting [numeric(21,0) (Types#NUMERIC)]

It seems that auto-created ddl is wrong. I cannot modify entities or any other properties in project, but I guess it's my local system issue. To ensure this, I tried to run the project with docker-compose - everything went fine and it started! Can you please suggest the possible reason of this happening and the solution?

I've tried to switch Postgre versions, Hibernate versions, my thoughts were maybe there is a problem with auto-generated ddl. Didn't work

Upvotes: 0

Views: 64

Answers (0)

Related Questions