Spring data jpa save can not get id

前端 未结 7 1337
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 01:09

My entity id is generated, and it was working fine when I use DAO instead of Spring data JPA.

@Id
@Column(name = TABLE_COLUM_NAME_ID)
@GeneratedValue
private         


        
7条回答
  •  清歌不尽
    2020-12-10 01:36

    Try this like

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

    Then after call to getId();

提交回复
热议问题