Laabidi Raissi (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-15544 (
https://hibernate.atlassian.net/browse/HHH-15544?atlOrigin=eyJpIjoiNDMzN2...
)
Re: OrderColumn invalid value on add for LAZY entity (
https://hibernate.atlassian.net/browse/HHH-15544?atlOrigin=eyJpIjoiNDMzN2...
)
Indeed, the issue is with the “int“ vs “Integer” types. What Hibernate does to store the
rank value is:
* insert the employee row
* *select max(rank) + 1 from employee* by the dept_id
* update the employee row inserted in 1) with the max+1 fetched in 2
Now if you have an “int” rank, the first employee to be inserted will have 0 rank (the
default value for the int type in java). The max(rank) + 1 will return 1, and the updated
value of the rank will be 1.
Whereas, when Integer is used, the employee would have null as default rank. The max(rank)
+ 1 returned from DB will be *NULL*. And so the updated value of the rank will be 0.
I don’t know if this is an intended behaviour or a bug.
(
https://hibernate.atlassian.net/browse/HHH-15544#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15544#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:520255c )