java - when run multiple times to insert JPA Entity id gives org.springframework.dao.DataIntegrityViolationException: could not execute statement; error -
org.springframework.dao.dataintegrityviolationexception: not execute statement;
@entity @table(name = "group") @jsoninclude(jsoninclude.include.non_null) public class contactgroup implements serializable{ private static final long serialversionuid = 7161778136151592279l; @id @genericgenerator(name = "increment", strategy = "increment") @generatedvalue(generator = "increment") @column(name = "grp_id") private long id;
}
in entity id primary key when insert data first time running , insert id 1 , if run again gives error can please tell me did wrong
if have table autoincrement, can use
@generatedvalue(strategy=generationtype.identity)
Comments
Post a Comment