I am trying to replace my database with Room persistence
I've a method which accept a Custom Object and return the id of that row is in database
/**
* This method return -1 if there is not any classInfo other wise return
* the id of the classInfo
*
* @param ClassInfo
* @return
*/
public int getClassIdByInfo(ClassInfo classInfo) {
Cursor c = db.query(DB_CLASS_INFO, new String[]{CL_ID}, CL_BRANCH
+ "=? AND " + CL_SEM + "=? AND " + CL_SECTION + "=?",
new String[]{classInfo.branch, classInfo.sem, classInfo.section}, null, null, null);
if (c.getCount() > 0) {
c.moveToFirst();
return c.getInt(0);
} else {
return -1;
}
I want to replace this method with Room persistence DAO method
@Dao
public interface StudentClassDao {
@Query("SELECT id FROM class_info....") //what will be the query?
int getClassIdByInfo(ClassInfo classInfo);
}
What will be the query for that scenario?