2

I'm trying to have a base class which id field is of a generic type like

class BaseEntity<T>{
  private T id;
  //get, set;
}
class User extends BaseEntity<String> {
  //blah blah blah
}

and I have a DAO like this:

@Dao
public interface UserDao {

    @Query("SELECT * FROM user WHERE id = :id")
    Flowable<User> getUserById(String id);
}

and I get a compilation error:

app\build\generated\source\apt\irrisimples\debug\com\irrisimples\data\source\local\UserDao_Impl.java:275: error: cannot find symbol final T _tmpId; ^

and in UserDao_Impl:275:

final T _tmpId; _tmpId = _cursor.getString(_cursorIndexOfId);

So this means that Room couldn't figure out what was T and replace the value there. Is it a bug or am I doing something wrong?

P.S: Using Android Studio 3.1 BETA 3, and Room 1.0.0 (tested 1.1.0-alpha2)

reinaldomoreira
  • 5,388
  • 3
  • 14
  • 29

1 Answers1

2

With reference to Google Issue Tracker

It should be fixed in 1.1.0-alpha3

Prags
  • 2,457
  • 2
  • 21
  • 38
reinaldomoreira
  • 5,388
  • 3
  • 14
  • 29