This repository was archived by the owner on Jul 25, 2024. It is now read-only.
Commit 2455df9
Check for person object before updating.
In AsynGetEvents.java, we receive realm_users from user-configuration
response. The person objects deserialized from response don't have an
id with them as it is supposed to be auto-generated in the database.
Hence, while creating or updating such objects we should make sure not
to use ormlite createOrUpdate method.
Here is the stackstrace for the error.
Non-fatal Exception: java.lang.RuntimeException: java.sql.SQLException: Unable to run insert stmt on object com.zulip.android.models.Person@55e51053: INSERT INTO `people` (`avatarUrl` ,`email` ,`isActive` ,`isBot` ,`name` ) VALUES (?,?,?,?,?)
at com.j256.ormlite.dao.RuntimeExceptionDao.createOrUpdate(RuntimeExceptionDao.java:277)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:171)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:127)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:227)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:169)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:150)
at com.zulip.android.networking.AsyncGetEvents.processRegister(AsyncGetEvents.java:126)
at com.zulip.android.networking.AsyncGetEvents.register(AsyncGetEvents.java:118)
at com.zulip.android.networking.AsyncGetEvents.run(AsyncGetEvents.java:204)
Caused by java.sql.SQLException: Unable to run insert stmt on object com.zulip.android.models.Person@55e51053: INSERT INTO `people` (`avatarUrl` ,`email` ,`isActive` ,`isBot` ,`name` ) VALUES (?,?,?,?,?)
at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:25)
at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:137)
at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:458)
at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:328)
at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:387)
at com.j256.ormlite.dao.RuntimeExceptionDao.createOrUpdate(RuntimeExceptionDao.java:274)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:171)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:127)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:227)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:169)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:150)
at com.zulip.android.networking.AsyncGetEvents.processRegister(AsyncGetEvents.java:126)
at com.zulip.android.networking.AsyncGetEvents.register(AsyncGetEvents.java:118)
at com.zulip.android.networking.AsyncGetEvents.run(AsyncGetEvents.java:204)
Caused by java.sql.SQLException: inserting to database failed: INSERT INTO `people` (`avatarUrl` ,`email` ,`isActive` ,`isBot` ,`name` ) VALUES (?,?,?,?,?)
at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:27)
at com.j256.ormlite.android.AndroidDatabaseConnection.insert(AndroidDatabaseConnection.java:180)
at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:91)
at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:458)
at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:328)
at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:387)
at com.j256.ormlite.dao.RuntimeExceptionDao.createOrUpdate(RuntimeExceptionDao.java:274)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:171)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:127)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:227)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:169)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:150)
at com.zulip.android.networking.AsyncGetEvents.processRegister(AsyncGetEvents.java:126)
at com.zulip.android.networking.AsyncGetEvents.register(AsyncGetEvents.java:118)
at com.zulip.android.networking.AsyncGetEvents.run(AsyncGetEvents.java:204)
Caused by android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: people.email (code 2067)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:786)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at com.j256.ormlite.android.AndroidDatabaseConnection.insert(AndroidDatabaseConnection.java:168)
at com.j256.ormlite.stmt.mapped.MappedCreate.insert(MappedCreate.java:91)
at com.j256.ormlite.stmt.StatementExecutor.create(StatementExecutor.java:458)
at com.j256.ormlite.dao.BaseDaoImpl.create(BaseDaoImpl.java:328)
at com.j256.ormlite.dao.BaseDaoImpl.createOrUpdate(BaseDaoImpl.java:387)
at com.j256.ormlite.dao.RuntimeExceptionDao.createOrUpdate(RuntimeExceptionDao.java:274)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:171)
at com.zulip.android.networking.AsyncGetEvents$1.call(AsyncGetEvents.java:127)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:227)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:169)
at com.j256.ormlite.misc.TransactionManager.callInTransaction(TransactionManager.java:150)
at com.zulip.android.networking.AsyncGetEvents.processRegister(AsyncGetEvents.java:126)
at com.zulip.android.networking.AsyncGetEvents.register(AsyncGetEvents.java:118)
at com.zulip.android.networking.AsyncGetEvents.run(AsyncGetEvents.java:204)1 parent 8dab1db commit 2455df9
File tree
1 file changed
+10
-2
lines changed- app/src/main/java/com/zulip/android/networking
1 file changed
+10
-2
lines changedLines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
170 | | - | |
171 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
| |||
0 commit comments