使用mbp插入数据后,会自动给entity的id赋值,因此直接获取entity.id即可

public void insertModel(Entity entity){
    save(entity);
    var newId=entity.getId();
}