我在AndroidX分支上使用roomVersion ='2.1.0-alpha03'
// Room (androidx)
implementation "androidx.room:room-runtime:$rootProject.roomVersion"
implementation "androidx.room:room-rxjava2:$rootProject.roomVersion"
implementation "androidx.room:room-guava:$rootProject.roomVersion"
testImplementation "androidx.room:room-testing:$rootProject.roomVersion"
annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
这是我的@DatabaseView查询:
@DatabaseView("SELECT * FROM DataPointJoin " +
"INNER JOIN Device ON Device.device_uid = DataPointJoin.device_uid " +
"INNER JOIN Measurement ON Measurement.measurement_uid = DataPointJoin.measurement_uid " +
"INNER JOIN Location ON Location.location_uid = DataPointJoin.location_uid " +
"INNER JOIN User ON User.user_uid = DataPointJoin.user_uid " +
"INNER JOIN SyncRecord ON SyncRecord.sync_uid = DataPointJoin.uid ")
这是我的用法示例:
@Query("SELECT * FROM DataPoint WHERE DataPoint.uid = :uid")
Flowable<Optional<DataPoint>> get(String uid);
在使用@DatabaseView()将联接封装到View中时,以及在清理并重建后: