What was observed?Windows + PostgreSQL 14 DatabaseHibernate throws the following schema validation exception:
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: wrong column type encountered in column [mycolumn] in table [mytable]; found [timestamptz (Types#TIMESTAMP)], but expecting [timestamp(6) with time zone (Types#TIMESTAMP_UTC)]
The underlying Java datatype is java.util.Instant. Linux + PostgreSQL 10 DatabaseThe exception is not thrown. Additional InformationIn both databases the information_schema describes the column as
data_type |
datetime_precision |
timestamp with time zone |
6 |
The column was created with an DDL statement containing timestamp(6) with time zone as datatype. What is the Bug?Hibernate states that the “found” datatype would be literally timestamptz, although postgres itself (via the information_schema) describes the datatype as timestamp with time zone. Actually it should not matter, because timestamptz is just an alias for timestamp with time zone but it is confusing where Hibernate gets the information from, because it clearly cannot be what the information schema offers. More precisely, the bug is that Hibernate claims the data type would be timestamptz although it
- has been created with timestamp(6) with timezone
- is described by IDEs (e.g. JetBrains Data Grip) as timestamp(6) with timezone
- is described by the information schema as timestamp with time zone with precision 6
So we can safely assume, that the datatype is actually timestamp(6) with timezone and therefore, exactly what Hibernate is expecting in the exception text: expecting timestamp(6) with time zone (Types#TIMESTAMP_UTC) Even if hibernate somehow internally recognizes timestamp with timezone as timestamptz (which imho is wrong, because Hibernate should use what the information schema says and should not work with its own interpretations), then the data types would still be the same, because timestamptz is just an alias. |