Reputation: 191
when I try to use Generic Dao in android Room I get this Erro :
Cannot use unbound generics in query methods. It must be bound to a type through base Dao class.
import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.RawQuery;
import android.arch.persistence.room.Update;
import java.util.List;
@Dao
public interface BaseDaoAccess<T> {
@Insert
Long Insert(T entity);
@Update
void Update(T entity);
@Delete
void Delete(T entity);
@RawQuery
LiveData<List<T>> RowQuery(String query);
}
Upvotes: 0
Views: 1042
Reputation: 77177
Due to type erasure, Java can't tell at runtime what T
you mean. You can provide this information by creating a subtype that has the T
bound to a specific type, such as this:
public interface CarDao extends BaseDaoAccess<Car> { }
Upvotes: 1