This is how I am inserting data into database using Room Persistence Library:
Entity:
@Entity
class User {
@PrimaryKey(autoGenerate = true)
public int id;
//...
}
Data access object:
@Dao
public interface UserDao{
@Insert(onConflict = IGNORE)
void insertUser(User user);
//...
}
Is it possible to return the id of User once the insertion is completed in the above method itself without writing a separate select query?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…