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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -