Gulab Sagevadiya
Gulab Sagevadiya

Reputation: 991

how to fire two queries in room database dao

I want to know how to fire two queries in Room database 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
}

I have Added Attendance entity class here Also for your ref

I don't know how to fire two queries.

Upvotes: 1

Views: 1240

Answers (1)

Sahitya Pasnoor
Sahitya Pasnoor

Reputation: 607

This should help you.

@Transaction allows you to create a function and call multiple queries in a single call.

https://developer.android.com/reference/androidx/room/Transaction

Upvotes: 4

Related Questions