からいくつかのデータを取得するために、複雑なデータベース ビューを作成しましたtables
。
@DatabaseView(viewName = "VIEW_SEDINTE_SPECIALE",
value = "SELECT descriere AS description, UPPER(titlu) AS upperTitle," +
"(CASE " +
"WHEN puncte_premiu * 2 > 100 THEN 100 " +
"ELSE puncte_premiu * 2 " +
"END) AS doubledRewards " +
"FROM sarcini")
public class SpecialTask {
public String upperTitle;
public String description;
public Long doubledRewards;
public SpecialTask(String upperTitle, String description, Long doubledRewards) {
this.upperTitle = upperTitle;
this.description = description;
this.doubledRewards = doubledRewards;
}
}
ドキュメントに従って、データベースにビューを指定しました:
@Database(
entities = {
Role.class, Task.class, TaskHistory.class, User.class,
Feedback.class, Location.class, Material.class,
SessionMaterial.class, SessionTask.class,
Problem.class, Session.class
},
views = {
SpecialTask.class
},
version = 1
)
@TypeConverters(DateConverter.class)
public abstract class PersonalDevelopmentDatabase extends RoomDatabase { ... }
そして、私はからしQueriesDao
たい:select everything
View
@Dao
public interface QueriesDao {
@Query("SELECT * FROM VIEW_SEDINTE_SPECIALE")
LiveData<List<SpecialTask>> getSpecialTasks();
}
そして、私は次のエラーで立ち往生しています:
There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: VIEW_SEDINTE_SPECIALE)
私は多くの投稿を調べましたが、解決策はありませんでした。これをどのように解決すればよいですか?