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
Post a Comment