androidx.room.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中androidx.room.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:androidx.room.Query
类名称:Query

Query介绍

暂无

代码示例

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT c.* FROM calendar c " +
    "WHERE NOT EXISTS (SELECT * FROM widgets_timetable_blacklist " +
    "WHERE widget_id=:widgetId AND c.title=lecture_title) " +
    "GROUP BY c.title")
List<CalendarItem> getLecturesNotInBlacklist(String widgetId);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT id, cafeteriaId, date, typeShort, typeLong, 0 AS typeNr, group_concat(name, '\n') AS name FROM cafeteriaMenu " +
      "WHERE cafeteriaId = :cafeteriaId AND date = :date " +
      "GROUP BY typeLong ORDER BY typeShort=\"tg\" DESC, typeShort ASC, typeNr")
  List<CafeteriaMenu> getTypeNameFromDbCard(int cafeteriaId, DateTime date);
}

代码示例来源:origin: YassinAJDI/PopularMovies

/**
 * Unfavorite a movie.
 *
 * @return the number of movies updated. This should always be 1.
 */
@Query("UPDATE movie SET is_favorite = 0 WHERE id = :movieId")
int unFavoriteMovie(long movieId);

代码示例来源:origin: zhiwei1990/android-jetpack-demo

/**
 * 这里就是使用了paging的DataSource,用于便捷加载分页数据
 *
 * @return
 */
@Query("SELECT * FROM Student ORDER BY name COLLATE NOCASE ASC")
DataSource.Factory<Integer, Student> getAllStudent();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT * " +
    "FROM events " +
    "WHERE EXISTS (SELECT * FROM tickets WHERE tickets.event_id = events.id) " +
    "ORDER BY start_time")
Observable<List<Event>> getAllBookedEvents();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT c.* FROM calendar c WHERE dtend BETWEEN :from AND :to "
    + "AND STATUS != 'CANCEL'"
    + "AND NOT EXISTS (SELECT * FROM widgets_timetable_blacklist WHERE widget_id = :widgetId"
    + "                AND lecture_title = c.title)"
    + "ORDER BY dtstart ASC")
List<CalendarItem> getNextDays(DateTime from, DateTime to, String widgetId);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT * FROM calendar WHERE nr=:id"
    + " UNION "
    + "SELECT * FROM calendar "
    + "WHERE title = (SELECT title FROM calendar WHERE nr=:id) "
    + "AND dtstart = (SELECT dtstart FROM calendar WHERE nr=:id) "
    + "AND dtend = (SELECT dtend FROM calendar WHERE nr=:id) "
    + "AND nr != :id "
    + "ORDER BY location ASC")
List<CalendarItem> getCalendarItemsById(String id);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("UPDATE chat_room SET last_read = "
      + "case when (select MAX(_id) from chat_message where room=:room) is null then -1 "
      + "else (select MAX(_id) from chat_message where room=:room) end "
    + "WHERE room=:room")
void markAsRead(int room);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT * " +
    "FROM events " +
    "WHERE start_time > date('now') " +
    "AND events.kino = -1 " +
    "ORDER BY start_time " +
    "LIMIT 1")
Event getNextEventWithoutMovie();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT r.*, m.timestamp, m.text, 0 as nr_unread " +
    "FROM chat_room r " +
    "LEFT JOIN (SELECT MAX(timestamp) timestamp, text, room FROM chat_message GROUP BY room) m ON (m.room=r.room) " +
    "WHERE joined=0 OR joined=-1 " +
    "ORDER BY r.semester!='', r.semester_id DESC, datetime(m.timestamp) DESC, r.name")
List<ChatRoomAndLastMessage> getAllRoomsNotJoinedList();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT r.* " +
    "FROM chat_room r, (SELECT semester_id FROM chat_room " +
    "WHERE (NOT semester_id IS NULL) AND semester_id!='' AND semester!='' " +
    "ORDER BY semester_id DESC LIMIT 1) AS new " +
    "WHERE r.semester_id=new.semester_id AND r.joined=-1")
List<ChatRoomDbRow> getNewUnjoined();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT r.* " +
    "FROM calendar c, room_locations r " +
    "WHERE datetime('now', 'localtime') < datetime(c.dtstart, '+1800 seconds') AND " +
    "datetime('now','localtime') < c.dtend AND r.title == c.location AND c.status!='CANCEL'" +
    "ORDER BY dtstart LIMIT 1")
RoomLocations getNextLectureCoordinates();

代码示例来源:origin: cbeyls/fosdem-companion-android

@Query("SELECT t.id, t.name, t.type FROM tracks t"
    + " JOIN events e ON t.id = e.track_id"
    + " WHERE e.day_index = :day"
    + " GROUP BY t.id"
    + " ORDER BY t.name ASC")
public abstract LiveData<List<Track>> getTracks(Day day);

代码示例来源:origin: cbeyls/fosdem-companion-android

/**
 * Returns all persons in alphabetical order.
 */
@Query("SELECT `rowid`, name"
    + " FROM persons"
    + " ORDER BY name COLLATE NOCASE")
public abstract DataSource.Factory<Integer, Person> getPersons();

代码示例来源:origin: cbeyls/fosdem-companion-android

@Query("SELECT p.`rowid`, p.name"
    + " FROM persons p"
    + " JOIN events_persons ep ON p.`rowid` = ep.person_id"
    + " WHERE ep.event_id = :event")
protected abstract List<Person> getPersons(Event event);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT c.* " +
    "FROM calendar c LEFT JOIN room_locations r ON " +
    "c.location=r.title " +
    "WHERE coalesce(r.latitude, '') = '' " +
    "GROUP BY c.location")
List<CalendarItem> getLecturesWithoutCoordinates();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT c.* FROM calendar c JOIN " +
    "(SELECT dtstart AS maxstart FROM calendar WHERE status!='CANCEL' AND datetime('now', 'localtime')<dtstart " +
    "ORDER BY dtstart LIMIT 1) ON status!='CANCEL' AND datetime('now', 'localtime')<dtend AND dtstart<=maxstart " +
    "ORDER BY dtend, dtstart LIMIT 4")
List<CalendarItem> getNextCalendarItems();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT * FROM calendar " +
    "WHERE status!='CANCEL' " +
    "AND dtstart > datetime('now', 'localtime') " +
    "GROUP BY title, dtstart, dtend " +
    "ORDER BY dtstart LIMIT 4")
List<CalendarItem> getNextUniqueCalendarItems();

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT location FROM calendar "
    + "WHERE title = (SELECT title FROM calendar WHERE nr=:id) "
    + "AND dtstart = (SELECT dtstart FROM calendar WHERE nr=:id) "
    + "AND dtend = (SELECT dtend FROM calendar WHERE nr=:id) "
    + "AND status != 'CANCEL' "
    + "ORDER BY location ASC")
List<String> getNonCancelledLocationsById(String id);

代码示例来源:origin: TUM-Dev/Campus-Android

@Query("SELECT * FROM news " +
    "WHERE src IN (:ids) " +
    "AND (src < 7 OR src > 13 OR src=:selectedNewspread) " +
    "ORDER BY date DESC")
List<News> getAll(Integer[] ids, int selectedNewspread);

相关文章