Incorrect DDL with Postgres, @MappedSuperclass, Generics and UserType

Description

This problem is similar to HHH-15970, but still exists with Hibernate 6.1.7.

It occurs when you have a generic @MappedSuperclass with an enum field that is mapped via a custom UserType. The databse field is generated as a bytea, where an integer type is expected. When saving an object, there is of course a type conflict.

Please have a look at the attached test case. With Hibernate 6.1.7 and Postgres it fails as follows:

Caused by: org.postgresql.util.PSQLException: ERROR: column "myenum" is of type bytea but expression is of type integer Hint: You will need to rewrite or cast the expression. Position: 93 at app//org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676) at app//org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366) at app//org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356) at app//org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496) at app//org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413) at app//org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190) at app//org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152) at app//org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)

With Hibernate 6.2, however, it is successful. I couldn't find a suitable JIRA issue for it though.

I would like to ask for a fix for 6.1. Because we are currently limited to JakartaEE 9.1, the use of Hibernate 6.2 is unfortunately not yet an option for us.

Attachments

1
  • 08 May 2023, 09:32 AM

Activity

Show:

Christian Beikov June 12, 2023 at 10:14 AM

Christoph Laudenbach May 30, 2023 at 11:54 AM

Is there already an initial analysis for this problem? It would be helpful for us to know, if a fix for 6.1 will be available.

Rejected

Details

Assignee

Reporter

Worked in

Affects versions

Priority

Created May 8, 2023 at 9:32 AM
Updated June 12, 2023 at 10:14 AM
Resolved June 12, 2023 at 10:14 AM