Room: Room is not generating views created via DatabaseView. When trying to query via select * from VIEW_NAME showing error There is a problem with the query: [SQLITE_ERROR] SQL error or missing database (no such table: VIEW_NAME)
@Database(entities = {BankEntity.class, BankRateEntity.class, CommentEntity.class, ExchangeOfficeEntity.class,
FBankEntity.class, FBankRateEntity.class, FRateEntity.class, RateByUserEntity.class,
RateInfoEntity.class, UserEntity.class, UserMessageEntity.class, UserRateEntity.class},
views = {BankRateView.class, ChatView.class, FBankRateView.class, RateInfoView.class, UserRateVew.class},
version = 9)
public abstract class RoomDB extends RoomDatabase {
....
}
@Query("SELECT * FROM " + TUserRate.VIEW_NAME +
" WHERE " + TUserRate.COLUMN_DELETED + " = 0" +
" AND " + TUserRate.COLUMN_OFFICE_ID + " = :officeId" +
" AND " + TUserRate.COLUMN_CURRENCY + " = :currency" +
" AND " + TUserRate.COLUMN_TIME + " > :time" +
" ORDER BY " +
TUserRate.COLUMN_USER_RATING + " DESC, " +
TUserRate.COLUMN_TIME + " DESC," +
"CASE WHEN :forBuying THEN "
+ TUserRate.COLUMN_BUY_RATE +
" ELSE "
+ TUserRate.COLUMN_SELL_RATE +
" END DESC" +
" LIMIT 1")
Single<UserRateVew> findTheBestUserRate(String officeId, String currency, Long time, boolean forBuying);
@Getter
@Setter
@DatabaseView(value = TUserRate.VIEW_SQL_CMD, viewName = TUserRate.VIEW_NAME)
public class UserRateVew {
@ColumnInfo(name = TUserRate.COLUMN_UNIQUE_ID)
@NonNull
private String uniqueId = MyUtils.getGuid();
@ColumnInfo(name = TUserRate.COLUMN_USER_NAME)
@NonNull
private String userName;
@ColumnInfo(name = TUserRate.COLUMN_COUNTRY)
@NonNull
private String country;
@ColumnInfo(name = TUserRate.COLUMN_CITY)
@NonNull
private String city;
@ColumnInfo(name = TUserRate.COLUMN_MARKET)
@NonNull
private String market;
@ColumnInfo(name = TUserRate.COLUMN_CURRENCY)
@NonNull
private String currency;
@ColumnInfo(name = TUserRate.COLUMN_SELL_RATE)
@NonNull
private Double sellRate;
@ColumnInfo(name = TUserRate.COLUMN_BUY_RATE)
@NonNull
private Double buyRate;
@ColumnInfo(name = TUserRate.COLUMN_UNIT)
@NonNull
private Integer unit = 1;
@ColumnInfo(name = TUserRate.COLUMN_TIME)
@NonNull
private Long time = MyUtils.getCalendarWithTimeZone().getTimeInMillis();
@ColumnInfo(name = TUserRate.COLUMN_ACTUAL)
@TypeConverters(BooleanTypeConverter.class)
private Boolean isActual = false;
@ColumnInfo(name = TUserRate.COLUMN_OFFICE_ID)
private String officeId;
@ColumnInfo(name = TUserRate.COLUMN_USER_RATING)
private float userRating;
}