I've been banging my head against this for the past few days. I have a pretty simple Android Room setup. Here's my entity:
Entity(tableName = "some_table")
public class SomeClass {
@PrimaryKey(autoGenerate = true)
@NonNull
int id;
// Other member variables
public SomeClass() {
}
public int getId(){
return id;
}
public void setId(int id){
this.id = id;
}
}
My Dao is pretty straight-forward as well:
@Dao
public interface SomeClassDao {
@Query("SELECT * FROM some_table")
List<SomeClass> getAll();
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertAll(List<SomeClass> someClass);
@Update
void update(SomeClass someClass);
@Delete
void delete(SomeClass someClass);
}
And nothing crazy going on with my database either:
@Database(entities = {SomeClass.class}, version = 1)
public abstract class SomeClassDatabase extends RoomDatabase {
public static final String DATABASE_NAME = "someApp";
public abstract SomeClassDao getDao();
}
I create my database within onCreate()
of my application class:
public class SomeApp extends Application {
private static SomeClassDatabase sDatabase;
@Override public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
sDatabase = Room.databaseBuilder(this, SomeClassDatabase.class, SomeClassDatabase.DATABASE_NAME).build();
}
public static ForecastDatabase getDatabase(){
return sDatabase;
}
}
I then insert the data into my DB using RxJava within my main activity. I don't think that portion would be a source of the problem. If so, please let me know and I'll update my post.
The issue that I'm facing is that when I inspect my database using Stetho, I have not one but two columns for my primary key. There are no other duplicate columns except for the id
member variable of SomeClass
- everything else is in order. Would anyone have any idea as to why this would be happening? Any insight into this would be greatly appreciated.