Davide D'Alto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiY2ExNzRkOTAw...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16365?atlOrigin=eyJpIjoiY2ExNz...
) HHH-16365 (
https://hibernate.atlassian.net/browse/HHH-16365?atlOrigin=eyJpIjoiY2ExNz...
) Wrong insert identity query generated when disabling use_get_generated_keys with Sql
Server (
https://hibernate.atlassian.net/browse/HHH-16365?atlOrigin=eyJpIjoiY2ExNz...
)
Change By: Davide D'Alto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Entity example:
{code:java} @Entity(name = "Flour")
@Table(name = "Flour")
public static class Flour {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
...
}{code}
and setting
{noformat}hibernate.jdbc.use_get_generated_keys = false{noformat}
will produce the following invalid query with Sql Server:
{code:sql}insert into Flour (description,name,type) values (?,?,?) returning id{code}
instead of ( ORM 5.6.14)
{code:sql}insert into Flour (description, name, type) values (?, ?, ?) select
scope_identity(){code}
or
I think the correct query should be:
{code:sql}insert into Flour (description, name, type) output inserted.id values (?, ?,
?){code}
Note that using the output syntax will also fix the issue for Hibernate Reactive
(
https://hibernate.atlassian.net/browse/HHH-16365#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16365#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#100221- sha1:d541bce )