org.springframework.dao.DataIntegrityViolationException

PreparedStatementCallback; SQL [insert into Employee (id, name, role) values (?,?,?)]; Cannot insert explicit value for identity column in table 'Employee' when IDENTITY_INSERT is set to OFF.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'Employee' when IDENTITY_INSERT is set to OFF.

Samebug tips0

We couldn't find tips for this exception.

Don't give up yet. Paste your full stack trace to get a solution.

Solutions on the web13

  • via symmetricds by psi_teck
    ,
  • Stack trace

    • org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [insert into Employee (id, name, role) values (?,?,?)]; Cannot insert explicit value for identity column in table 'Employee' when IDENTITY_INSERT is set to OFF.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'Employee' when IDENTITY_INSERT is set to OFF. at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:658) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:907) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:968) at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:978) at com.journaldev.spring.jdbc.dao.EmployeeDAOJDBCTemplateImpl.save(EmployeeDAOJDBCTemplateImpl.java:32) at com.journaldev.spring.jdbc.main.SpringMain.main(SpringMain.java:31)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    We couldn't find other users who have seen this exception.