IT Support (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTlhMTA4MGE2...
) / Sub-task (
https://hibernate.atlassian.net/browse/HHH-13970?atlOrigin=eyJpIjoiNTlhMT...
) HHH-13970 (
https://hibernate.atlassian.net/browse/HHH-13970?atlOrigin=eyJpIjoiNTlhMT...
) SQL Server needs special handling for Identity column inserts (
https://hibernate.atlassian.net/browse/HHH-13970?atlOrigin=eyJpIjoiNTlhMT...
)
Change By: IT Support (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
SQL Server Identity inserts are different than in other databases, an error message is
generated when the {{org.hibernate.dialect.SQLServerDialect}} is updated to return
{{true}} from {{supportsCompositeNestedIdentityColumns()}}(examples from
[
sql-server-helper.com|http://www.sql-server-helper.com/error-messages/msg...])
{noformat}Server: Msg 339, Level 15, State 1, Line 1
DEFAULT or NULL are not allowed as explicit identity
values.{noformat}
The following INSERT statement will generate the error:
{code:sql}INSERT INTO [dbo].[SuperHero] ( [SuperHeroID], [SuperHeroName], [FirstName],
[LastName] )
VALUES ( DEFAULT, 'Superman', 'Clark', 'Kent' )
Msg 339, Level 16, State 1, Line 1
DEFAULT or NULL are not allowed as explicit identity values.{code}
Similarly, the following INSERT statement will also generate the error:
{code:sql}INSERT INTO [dbo].[SuperHero] ( [SuperHeroID], [SuperHeroName], [FirstName],
[LastName] )
VALUES ( NULL, 'Spiderman', 'Peter', 'Parker' )
Msg 339, Level 16, State 1, Line 1
DEFAULT or NULL are not allowed as explicit identity values.{code}
To avoid this error, when inserting into a table with an IDENTITY column, do not include
the IDENTITY column in the INSERT statement and let SQL Server assign the value to this
column for each row inserted to the table.
{noformat}INSERT INTO [dbo].[SuperHero] ( [SuperHeroName], [FirstName], [LastName] )
VALUES ( 'Superman', 'Clark', 'Kent' )
INSERT INTO [dbo].[SuperHero] ( [SuperHeroName], [FirstName], [LastName] )
VALUES ( 'Spiderman', 'Peter', 'Parker' ){noformat}
As such the Identity insert generation in the SQL Server Dialects remove the Identity
column.
[
https://hibernate.atlassian.net/browse/HHH-9662|https://hibernate.atlassi...]
reformulates how it all works and now the SQL Server Dialects need to be updated
specially.
(
https://hibernate.atlassian.net/browse/HHH-13970#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-13970#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#100125- sha1:0a83519 )