I'm using RxRoom with Kotlin. In my Dao class If I use this:
@Insert
fun insertPaymentRef(paymentRef: PaymentRef): Single<Long>
Or this:
@Insert
fun insertPaymentRef(paymentRef: PaymentRef): Completable
the generated Dao
class throws this error
error: local variable paymentRef is accessed from within inner class; needs to be declared final
A sneek peak in the generated class is this:
public Single<Long> insertPaymentRef(PaymentRef paymentRef) {
return Single.fromCallable(new Callable<Long>() {
@Override
public Long call() throws Exception {
__db.beginTransaction();
try {
long _result = __insertionAdapterOfPaymentRef.insertAndReturnId(paymentRef);
__db.setTransactionSuccessful();
return _result;
} finally {
__db.endTransaction();
}
}
});
}
The only time I don't get this error is if I only make my insert
call like this:
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertPaymentRef(paymentRef: PaymentRef)
How do I make the INSERT
call work in RxRoom: I've included RxRoom dependency and it works because if I try doing GET
calls like this
@Query(PaymentRefDbConstants.QUERY_PAYMENT_REF)
fun getPaymentRef(): Single<PaymentRef>
It works