Spring data jpa save can not get id -


my entity id generated, , working fine when use dao instead of spring data jpa.

@id @column(name = table_colum_name_id) @generatedvalue private int id; 

now have starting use spring data jpa, , after call repository.save(myboject), or repository.saveandflush(myobject), call myobject.getid(). id never populated.

i searched database , object in database , id correct. know why id not set after called save()? have no issue when use entitymanager.save().

try like

myboject = repository.save(myboject); repository.flush(); 

then after call getid();


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -