Oleksii Miroshnyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a157d9...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMGQ2NWZiYjMz...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16634?atlOrigin=eyJpIjoiMGQ2NW...
) HHH-16634 (
https://hibernate.atlassian.net/browse/HHH-16634?atlOrigin=eyJpIjoiMGQ2NW...
) Table generator id generation strategy returns too low number, doesn't respect
initial value from the table (
https://hibernate.atlassian.net/browse/HHH-16634?atlOrigin=eyJpIjoiMGQ2NW...
)
Issue Type: Bug Affects Versions: 6.2.2 Assignee: Unassigned Components:
hibernate-orm-modules Created: 18/May/2023 06:22 AM Priority: Major Reporter: Oleksii
Miroshnyk (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a157d9...
)
Tried the following test case in hibernate 6.2.2:
Created entity with the following setup for id
@GeneratedValue(generator= "entityD", strategy = GenerationType.TABLE)
@TableGenerator(name = "entityD", table="my_seq",pkColumnName =
"my_seq_name", valueColumnName = "my_seq_val")
after that update generator for corresponding entity to 50 in the my_seq table via sql.
and ask hibernate to insert new entity.
The id will be assigned is 2, while I would expect 51…(or 52, or >50 I don’t care)
if I update generator to 100, the assigned id will be 52…
Seems a bug? In prev versions(3-5) it was working as expected.
Looking briefly in the code I see hibernate reads value from the table, updates with
increment and then returns the value that was read, and after that applies formula value
read - (increment size-1).
Seems logic should either return value after update or don’t substract increment size,
which is 50 by default…
(
https://hibernate.atlassian.net/browse/HHH-16634#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16634#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#100225- sha1:d57183e )