hypersistence-utils: ArrayType causes org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column found (Types#ARRAY), but expecting (Types#OTHER) with Hibernate 6.3 and 6.4

Describe the bug When I upgrade from

hypersistence-utils-hibernate-62:3.7.1 to hypersistence-utils-hibernate-63:3.7.1

The following code:

@Type(
     value = ListArrayType::class,
     parameters = [Parameter(
         value = "house",
         name = ListArrayType.SQL_ARRAY_TYPE,
     )]
 )
 @Column(columnDefinition = "house[]")
 val houses: List<House>,

Throws this error:

org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [houses] in table [dok_card]; found [_house (Types#ARRAY)], but expecting [house[] (Types#OTHER)]

My hibernate version is 6.4.1.Final.

To Reproduce

Follow the instructions here: https://vladmihalcea.com/postgresql-array-java-list/ with the latest version of hibernate and hypersistence-utils.

Expected behavior No error is thrown when using a postgresql array of enums with a java list.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 6
  • Comments: 20 (10 by maintainers)

Most upvoted comments

@kth13 Remove the @Type annotation and see if it works.

How to implement array of SQL enum in 6.4?

    @Type(
        value = EnumArrayType.class,
        parameters = @Parameter(
            name = AbstractArrayType.SQL_ARRAY_TYPE,
            value = "status"
        )
    )
    @Column(name = "statuses", columnDefinition = "status[]")
    private Status[] statuses;

Native Type support cause the following error on saving: column "statuses" is of type status[] but expression is of type smallint[]

Great. The native Hibernate Type should be fine in many situations.

You should open a Hibernate issue then. In the long run, it’s better to have the native Type support everything this library has been supporting.

@hahosseini Well, you said that the PostgreSQLEnumArrayTypeTest solution doesn’t work, and it does work.

Now, it’s obvious that you are getting that wrong column type warning since this issue is still open, right?

The only way to get rid of that warning is if you fix HHH-17588 in Hibernate. Be the change you want to see in this world!

Hi @vladmihalcea , I am facing the similar issue The code we have

@Type(ListArrayType::class) @Column(name = "disabilities", columnDefinition = "text[]") var disabilities: List<String>? = null,

What is your suggestion to change this using Hibernate native support

The only known regressions are the ones for which there are Open issues on GitHub. There might be unknown regressions, of course.

Native Type support is what Hibernate ORM offers by default without the need for custom UserType implementations.

The tests in the 63 module are running fine on Hibernate 6.4. That’s the only thing I can confirm. If there are other issues, they will have to be replicated with additional integration tests.

If your project has integration tests for the entire data access logic, then you will know for sure whether a native Type or a custom one works or not. That’s thr only confirmation that really matters.