我想知道如何在Room数据库Dao中触发两个查询。
@Dao
public interface AttendanceDao {
@Query("Select * from Mattendance where Date = :date AND studentId = :id")
Mattendance getAttendanceByDate(Date date, int id);
@Entity
public class Mattendance {
@PrimaryKey(autoGenerate = true)
int id;
int studentId;
int batchId;
String studentName;
String batchName;
String status;
Date date;
public Mattendance(int studentId, int batchId, String studentName, String batchName, String status, Date date) {
this.studentId = studentId;
this.batchId = batchId;
this.studentName = studentName;
this.batchName = batchName;
this.status = status;
this.date = date;
}
all Getters And setters
didn't added because stackoverflow showing error of to much of code and lesser information
}
我还在这里添加了出勤实体类,供您参考
我不知道如何触发两个查询。
答案 0 :(得分:1)
这应该对您有帮助。
@Transaction
允许您创建一个函数并在一个调用中调用多个查询。
https://developer.android.com/reference/android/arch/persistence/room/Transaction