jonathanarodr/playmovie

Erro ao adicionar favorito SQLiteConstraintException

Closed this issue · 0 comments

Se filme é listado nas abas popular e top rate ao incluir como favorito é gerado uma SQLiteConstraintException

2019-11-03 22:58:48.471 6203-6252/br.com.jonathanarodr.playmovie E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1
    Process: br.com.jonathanarodr.playmovie, PID: 6203
    android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: movies.id (code 1555 SQLITE_CONSTRAINT_PRIMARYKEY)
        at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
        at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:879)
        at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
        at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:88)
        at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.java:51)
        at androidx.room.EntityInsertionAdapter.insert(EntityInsertionAdapter.java:64)
        at br.com.jonathanarodr.playmovie.data.MovieDao_Impl.insertMovie(MovieDao_Impl.java:92)
        at br.com.jonathanarodr.playmovie.data.MovieRepository.insertFavoriteMovie(MovieRepository.kt:120)
        at br.com.jonathanarodr.playmovie.viewmodel.MovieViewModel.insertFavoriteMovie(MovieViewModel.kt:45)
        at br.com.jonathanarodr.playmovie.ui.DetailActivity$5.run(DetailActivity.java:197)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)