Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 1 | import android.database.Cursor |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 2 | import androidx.room.EntityInsertionAdapter |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 3 | import androidx.room.RoomDatabase |
| 4 | import androidx.room.RoomSQLiteQuery |
| 5 | import androidx.room.RoomSQLiteQuery.Companion.acquire |
| 6 | import androidx.room.util.getColumnIndexOrThrow |
| 7 | import androidx.room.util.query |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 8 | import androidx.sqlite.db.SupportSQLiteStatement |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 9 | import java.lang.Class |
Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 10 | import javax.`annotation`.processing.Generated |
| 11 | import kotlin.ByteArray |
| 12 | import kotlin.Int |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 13 | import kotlin.String |
Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 14 | import kotlin.Suppress |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 15 | import kotlin.collections.List |
| 16 | import kotlin.jvm.JvmStatic |
Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 17 | |
| 18 | @Generated(value = ["androidx.room.RoomProcessor"]) |
elifbilgin | d46e8c1 | 2023-01-17 09:32:11 -0800 | [diff] [blame] | 19 | @Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION"]) |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 20 | public class MyDao_Impl( |
| 21 | __db: RoomDatabase, |
| 22 | ) : MyDao { |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 23 | private val __db: RoomDatabase |
| 24 | |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 25 | private val __insertionAdapterOfMyEntity: EntityInsertionAdapter<MyEntity> |
Daniel Santiago Rivera | e695d18 | 2022-11-08 21:12:14 -0500 | [diff] [blame] | 26 | init { |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 27 | this.__db = __db |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 28 | this.__insertionAdapterOfMyEntity = object : EntityInsertionAdapter<MyEntity>(__db) { |
| 29 | public override fun createQuery(): String = |
| 30 | "INSERT OR ABORT INTO `MyEntity` (`pk`,`byteArray`,`nullableByteArray`) VALUES (?,?,?)" |
| 31 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 32 | public override fun bind(statement: SupportSQLiteStatement, entity: MyEntity) { |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 33 | statement.bindLong(1, entity.pk.toLong()) |
| 34 | statement.bindBlob(2, entity.byteArray) |
Daniel Santiago Rivera | bb3ff86 | 2023-03-24 10:55:09 -0400 | [diff] [blame] | 35 | val _tmpNullableByteArray: ByteArray? = entity.nullableByteArray |
| 36 | if (_tmpNullableByteArray == null) { |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 37 | statement.bindNull(3) |
| 38 | } else { |
Daniel Santiago Rivera | bb3ff86 | 2023-03-24 10:55:09 -0400 | [diff] [blame] | 39 | statement.bindBlob(3, _tmpNullableByteArray) |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
Daniel Santiago Rivera | a6dec5a | 2023-05-02 15:09:07 -0400 | [diff] [blame] | 45 | public override fun addEntity(item: MyEntity) { |
Daniel Santiago Rivera | 0552a38 | 2022-10-05 23:11:51 -0400 | [diff] [blame] | 46 | __db.assertNotSuspendingTransaction() |
| 47 | __db.beginTransaction() |
| 48 | try { |
| 49 | __insertionAdapterOfMyEntity.insert(item) |
| 50 | __db.setTransactionSuccessful() |
| 51 | } finally { |
| 52 | __db.endTransaction() |
| 53 | } |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | public override fun getEntity(): MyEntity { |
| 57 | val _sql: String = "SELECT * FROM MyEntity" |
| 58 | val _statement: RoomSQLiteQuery = acquire(_sql, 0) |
| 59 | __db.assertNotSuspendingTransaction() |
| 60 | val _cursor: Cursor = query(__db, _statement, false, null) |
| 61 | try { |
| 62 | val _cursorIndexOfPk: Int = getColumnIndexOrThrow(_cursor, "pk") |
| 63 | val _cursorIndexOfByteArray: Int = getColumnIndexOrThrow(_cursor, "byteArray") |
| 64 | val _cursorIndexOfNullableByteArray: Int = getColumnIndexOrThrow(_cursor, "nullableByteArray") |
| 65 | val _result: MyEntity |
| 66 | if (_cursor.moveToFirst()) { |
| 67 | val _tmpPk: Int |
| 68 | _tmpPk = _cursor.getInt(_cursorIndexOfPk) |
| 69 | val _tmpByteArray: ByteArray |
| 70 | _tmpByteArray = _cursor.getBlob(_cursorIndexOfByteArray) |
| 71 | val _tmpNullableByteArray: ByteArray? |
| 72 | if (_cursor.isNull(_cursorIndexOfNullableByteArray)) { |
| 73 | _tmpNullableByteArray = null |
| 74 | } else { |
| 75 | _tmpNullableByteArray = _cursor.getBlob(_cursorIndexOfNullableByteArray) |
| 76 | } |
| 77 | _result = MyEntity(_tmpPk,_tmpByteArray,_tmpNullableByteArray) |
| 78 | } else { |
elifbilgin | 22935ce | 2023-07-25 14:14:10 -0700 | [diff] [blame^] | 79 | error("The query result was empty, but expected a single row to return a NON-NULL object of type <MyEntity>.") |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 80 | } |
| 81 | return _result |
| 82 | } finally { |
| 83 | _cursor.close() |
| 84 | _statement.release() |
Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 85 | } |
Daniel Santiago Rivera | 885c9eb | 2022-09-29 21:49:35 -0400 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | public companion object { |
| 89 | @JvmStatic |
| 90 | public fun getRequiredConverters(): List<Class<*>> = emptyList() |
Daniel Santiago Rivera | 155f7ec | 2022-09-26 22:36:29 -0400 | [diff] [blame] | 91 | } |
| 92 | } |