After moving to SQL Server 2008, EclipseLink fails to auto-generate IDs because LAST_INSERT_ID is unrecognized.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "APP_ACCOUNTS")
private Integer acctId;
After moving to SQL Server 2008, EclipseLink fails to auto-generate IDs because LAST_INSERT_ID is unrecognized.
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "APP_ACCOUNTS")
private Integer acctId;
In my experience with similar setups, the issue stems from a mismatch between the SQL dialect expectations and the EclipseLink generation settings. SQL Server does not recognize LAST_INSERT_ID because it utilizes SCOPE_IDENTITY() for retrieving identity values. Adjusting the EclipseLink configuration to explicitly support SQL Server’s identity retrieval mechanisms helped resolve the problem in my project. Consolidating settings in both the persistence.xml file and the dialect-specific configurations provided a consistent approach, ensuring that auto-generated keys were correctly handled upon insertion in the SQL Server environment.