Mike Becker (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6321cb8...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2NjZjdmMTFm...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-15548?atlOrigin=eyJpIjoiN2NjZj...
) HHH-15548 (
https://hibernate.atlassian.net/browse/HHH-15548?atlOrigin=eyJpIjoiN2NjZj...
) PostgreSQL: Hibernate claims to have found "timestamptz" and also claims that
it is incompatible with "timestamp with timezone" (
https://hibernate.atlassian.net/browse/HHH-15548?atlOrigin=eyJpIjoiN2NjZj...
)
Issue Type: Bug Affects Versions: 6.1.3 Assignee: Unassigned Components: hibernate-core
Created: 26/Sep/2022 03:09 AM Priority: Major Reporter: Mike Becker (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6321cb8...
)
------------------
What was observed?
------------------
Windows + PostgreSQL 14 Database
--------------------------------
Hibernate 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 Database
------------------------------
The exception is not thrown.
----------------------
Additional Information
----------------------
In 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) ( #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.
(
https://hibernate.atlassian.net/browse/HHH-15548#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15548#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100207- sha1:1c92a42 )