[JIRA] (HHH-16779) EntityManager.find(Class<T> entityClass, Object primaryKey) generate unexpected sql
by 周雁鸣 (JIRA)
周雁鸣 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNWNiMDlmNzFl... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiNWNiMD... ) HHH-16779 ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiNWNiMD... ) EntityManager.find(Class<T> entityClass, Object primaryKey) generate unexpected sql ( https://hibernate.atlassian.net/browse/HHH-16779?atlOrigin=eyJpIjoiNWNiMD... )
Issue Type: Bug Affects Versions: 6.2.4 Assignee: Unassigned Components: regression Created: 12/Jun/2023 00:54 AM Priority: Major Reporter: 周雁鸣 ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Before hibernate 6.2
o.h. SQL DEBUG select t1_0.id,t1_0. index from test_entity t1_0 where t1_0.id=?
o.h.o.j.bind TRACE binding parameter [1] as [ ARRAY ] - [1]
Since hibernate 6.2
o.h. SQL DEBUG select t1_0.id,t1_0. index from test_entity t1_0 where array_contains(?,t1_0.id)
o.h.o.j.bind TRACE binding parameter [1] as [ ARRAY ] - [[1, null , null , null , null , null , null , null , null , null ]]
Does it changed by designed? if it is, please add an option to let user revert, and improve the migration document.
( https://hibernate.atlassian.net/browse/HHH-16779#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16779#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:956085d )
2 years, 10 months
[JIRA] (HHH-16778) TimeZoneStorageType.NORMALIZE_UTC & COLUMN not normalized to UTC
by Ivan Andrianto (JIRA)
Ivan Andrianto ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTc4MmE4Njdh... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16778?atlOrigin=eyJpIjoiYTc4Mm... ) HHH-16778 ( https://hibernate.atlassian.net/browse/HHH-16778?atlOrigin=eyJpIjoiYTc4Mm... ) TimeZoneStorageType.NORMALIZE_UTC & COLUMN not normalized to UTC ( https://hibernate.atlassian.net/browse/HHH-16778?atlOrigin=eyJpIjoiYTc4Mm... )
Change By: Ivan Andrianto ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I have this column. As I know, the time should be normalized to UTC in the database
{noformat}public class Purchase {
@Id
@GeneratedValue
@GenericGenerator(name = "UUID", type = UuidGenerator.class)
private UUID id;
@TimeZoneStorage(TimeZoneStorageType.TIMESTAMP_UTC)
private ZonedDateTime purchasedAt;
}{noformat}
Then, I try to save a record, where the time is created using {{ZonedDateTime}} with a non UTC {{ZoneId}} (the same as the local system).
{noformat}ZonedDateTime time = ZonedDateTime.of(2023, 6, 11, 15, 0, 0, 0, ZoneId.of("Asia/Jakarta"));
Purchase purchase = new Purchase();
puchase.setPurchasedAt(time);
Purchase savedPurchase = purchaseRepository.save(purchase);
Purchase retrievedPurchase = purchaseRepository.findById(savedPurchase.getId());{noformat}
The expected value should be {{2023-06-11 08:00:00}} (normalized to UTC), but I got {{2023-06-11 15:00:00}} in the database
I use PostgreSQL 12 and the column type is timestamp without timezone
Then, when the record is retrieved, the column value is {{2023-06-11T15:00Z}} which is incorrect.
I have seen the related code change in [https://github.com/hibernate/hibernate-orm/pull/4940/commits/7e4bacb1126b...]
But somehow the data stored in the database is incorrect
The value from hibernate log is {{binding parameter [2] as [TIMESTAMP_UTC] - [2023-06-11T08:00:00Z]}}
The parameter value from PostgreSQL log when inserting is {{$2 = '2023-06-11 15:00:00+07'}} (and stored in the database as {{2023-06-11 15:00:00}})
The same also applies for {{TimeZoneStorageType.COLUMN}}
( https://hibernate.atlassian.net/browse/HHH-16778#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16778#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:956085d )
2 years, 10 months