【发布时间】:2018-04-20 21:57:24
【问题描述】:
我需要检索最近插入的实体的生成 id 值,如下面添加的代码示例所示:
如上所述,实体Student 的id 字段使用PrimaryKey(autoGenerate= true) 进行注释。
Student s = new Student();
s.setName("foo");
// call of other setters
appDatabase.getGenericDAO().insertStudent(s);
// Now I need to retrieve the value of generated id as we do in Hibernate by the usage of merge method
Integer id = s.getId();
道
@Dao
public interface IGenericDAO {
@Insert
Long insertStudent(Student student);
@Insert
void insertOgrenci(List<Student> studentList);
@Update
void updateOgrenci(Ogrenci... ogrenci);
@Delete
void deleteOgrenci(Ogrenci... ogrenci);
}
【问题讨论】:
标签: android sqlite android-sqlite android-room