package world.respect.datalayer.db.school.xapi.daos

import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.util.appendPlaceholders
import androidx.room.util.getColumnIndexOrThrow
import androidx.room.util.performSuspending
import androidx.sqlite.SQLiteStatement
import javax.`annotation`.processing.Generated
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.MutableList
import kotlin.collections.mutableListOf
import kotlin.reflect.KClass
import kotlin.text.StringBuilder
import kotlin.time.Instant
import world.respect.datalayer.db.school.SchoolTypeConverters
import world.respect.datalayer.db.school.xapi.entities.XapiActorEntity
import world.respect.datalayer.db.school.xapi.entities.XapiActorEntityTypeEnum
import world.respect.datalayer.db.shared.SharedConverters

@Generated(value = ["androidx.room.RoomProcessor"])
@Suppress(names = ["UNCHECKED_CAST", "DEPRECATION", "REDUNDANT_PROJECTION", "REMOVAL"])
public class XapiActorDao_Impl(
  __db: RoomDatabase,
) : XapiActorDao {
  private val __db: RoomDatabase

  private val __insertAdapterOfXapiActorEntity: EntityInsertAdapter<XapiActorEntity>

  private val __sharedConverters: SharedConverters = SharedConverters()

  private val __schoolTypeConverters: SchoolTypeConverters = SchoolTypeConverters()

  private val __insertAdapterOfXapiActorEntity_1: EntityInsertAdapter<XapiActorEntity>
  init {
    this.__db = __db
    this.__insertAdapterOfXapiActorEntity = object : EntityInsertAdapter<XapiActorEntity>() {
      protected override fun createQuery(): String = "INSERT OR IGNORE INTO `XapiActorEntity` (`actorUid`,`actorPersonUid`,`actorName`,`actorMbox`,`actorMbox_sha1sum`,`actorOpenid`,`actorAccountName`,`actorAccountHomePage`,`actorStored`,`actorLastModified`,`actorGroupMembersLastUpdated`,`actorIsAnonGroup`,`actorObjectType`) VALUES (nullif(?, 0),?,?,?,?,?,?,?,?,?,?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: XapiActorEntity) {
        statement.bindLong(1, entity.actorUid)
        statement.bindLong(2, entity.actorPersonUid)
        val _tmpActorName: String? = entity.actorName
        if (_tmpActorName == null) {
          statement.bindNull(3)
        } else {
          statement.bindText(3, _tmpActorName)
        }
        val _tmpActorMbox: String? = entity.actorMbox
        if (_tmpActorMbox == null) {
          statement.bindNull(4)
        } else {
          statement.bindText(4, _tmpActorMbox)
        }
        val _tmpActorMbox_sha1sum: String? = entity.actorMbox_sha1sum
        if (_tmpActorMbox_sha1sum == null) {
          statement.bindNull(5)
        } else {
          statement.bindText(5, _tmpActorMbox_sha1sum)
        }
        val _tmpActorOpenid: String? = entity.actorOpenid
        if (_tmpActorOpenid == null) {
          statement.bindNull(6)
        } else {
          statement.bindText(6, _tmpActorOpenid)
        }
        val _tmpActorAccountName: String? = entity.actorAccountName
        if (_tmpActorAccountName == null) {
          statement.bindNull(7)
        } else {
          statement.bindText(7, _tmpActorAccountName)
        }
        val _tmpActorAccountHomePage: String? = entity.actorAccountHomePage
        if (_tmpActorAccountHomePage == null) {
          statement.bindNull(8)
        } else {
          statement.bindText(8, _tmpActorAccountHomePage)
        }
        val _tmp: Long? = __sharedConverters.fromInstant(entity.actorStored)
        if (_tmp == null) {
          statement.bindNull(9)
        } else {
          statement.bindLong(9, _tmp)
        }
        val _tmp_1: Long? = __sharedConverters.fromInstant(entity.actorLastModified)
        if (_tmp_1 == null) {
          statement.bindNull(10)
        } else {
          statement.bindLong(10, _tmp_1)
        }
        val _tmp_2: Long? = __sharedConverters.fromInstant(entity.actorGroupMembersLastUpdated)
        if (_tmp_2 == null) {
          statement.bindNull(11)
        } else {
          statement.bindLong(11, _tmp_2)
        }
        val _tmp_3: Int = if (entity.actorIsAnonGroup) 1 else 0
        statement.bindLong(12, _tmp_3.toLong())
        val _tmp_4: Int = __schoolTypeConverters.fromActorEntityTypeEnum(entity.actorObjectType)
        statement.bindLong(13, _tmp_4.toLong())
      }
    }
    this.__insertAdapterOfXapiActorEntity_1 = object : EntityInsertAdapter<XapiActorEntity>() {
      protected override fun createQuery(): String = "INSERT OR REPLACE INTO `XapiActorEntity` (`actorUid`,`actorPersonUid`,`actorName`,`actorMbox`,`actorMbox_sha1sum`,`actorOpenid`,`actorAccountName`,`actorAccountHomePage`,`actorStored`,`actorLastModified`,`actorGroupMembersLastUpdated`,`actorIsAnonGroup`,`actorObjectType`) VALUES (nullif(?, 0),?,?,?,?,?,?,?,?,?,?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: XapiActorEntity) {
        statement.bindLong(1, entity.actorUid)
        statement.bindLong(2, entity.actorPersonUid)
        val _tmpActorName: String? = entity.actorName
        if (_tmpActorName == null) {
          statement.bindNull(3)
        } else {
          statement.bindText(3, _tmpActorName)
        }
        val _tmpActorMbox: String? = entity.actorMbox
        if (_tmpActorMbox == null) {
          statement.bindNull(4)
        } else {
          statement.bindText(4, _tmpActorMbox)
        }
        val _tmpActorMbox_sha1sum: String? = entity.actorMbox_sha1sum
        if (_tmpActorMbox_sha1sum == null) {
          statement.bindNull(5)
        } else {
          statement.bindText(5, _tmpActorMbox_sha1sum)
        }
        val _tmpActorOpenid: String? = entity.actorOpenid
        if (_tmpActorOpenid == null) {
          statement.bindNull(6)
        } else {
          statement.bindText(6, _tmpActorOpenid)
        }
        val _tmpActorAccountName: String? = entity.actorAccountName
        if (_tmpActorAccountName == null) {
          statement.bindNull(7)
        } else {
          statement.bindText(7, _tmpActorAccountName)
        }
        val _tmpActorAccountHomePage: String? = entity.actorAccountHomePage
        if (_tmpActorAccountHomePage == null) {
          statement.bindNull(8)
        } else {
          statement.bindText(8, _tmpActorAccountHomePage)
        }
        val _tmp: Long? = __sharedConverters.fromInstant(entity.actorStored)
        if (_tmp == null) {
          statement.bindNull(9)
        } else {
          statement.bindLong(9, _tmp)
        }
        val _tmp_1: Long? = __sharedConverters.fromInstant(entity.actorLastModified)
        if (_tmp_1 == null) {
          statement.bindNull(10)
        } else {
          statement.bindLong(10, _tmp_1)
        }
        val _tmp_2: Long? = __sharedConverters.fromInstant(entity.actorGroupMembersLastUpdated)
        if (_tmp_2 == null) {
          statement.bindNull(11)
        } else {
          statement.bindLong(11, _tmp_2)
        }
        val _tmp_3: Int = if (entity.actorIsAnonGroup) 1 else 0
        statement.bindLong(12, _tmp_3.toLong())
        val _tmp_4: Int = __schoolTypeConverters.fromActorEntityTypeEnum(entity.actorObjectType)
        statement.bindLong(13, _tmp_4.toLong())
      }
    }
  }

  public override suspend fun insertOrIgnoreListAsync(entities: List<XapiActorEntity>): Unit = performSuspending(__db, false, true) { _connection ->
    __insertAdapterOfXapiActorEntity.insert(_connection, entities)
  }

  public override suspend fun upsertListAsync(entities: List<XapiActorEntity>): Unit = performSuspending(__db, false, true) { _connection ->
    __insertAdapterOfXapiActorEntity_1.insert(_connection, entities)
  }

  public override suspend fun findByUidAsync(uid: Long): XapiActorEntity? {
    val _sql: String = """
        |
        |        SELECT XapiActorEntity.*
        |          FROM XapiActorEntity
        |         WHERE XapiActorEntity.actorUid = ?
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, uid)
        val _columnIndexOfActorUid: Int = getColumnIndexOrThrow(_stmt, "actorUid")
        val _columnIndexOfActorPersonUid: Int = getColumnIndexOrThrow(_stmt, "actorPersonUid")
        val _columnIndexOfActorName: Int = getColumnIndexOrThrow(_stmt, "actorName")
        val _columnIndexOfActorMbox: Int = getColumnIndexOrThrow(_stmt, "actorMbox")
        val _columnIndexOfActorMboxSha1sum: Int = getColumnIndexOrThrow(_stmt, "actorMbox_sha1sum")
        val _columnIndexOfActorOpenid: Int = getColumnIndexOrThrow(_stmt, "actorOpenid")
        val _columnIndexOfActorAccountName: Int = getColumnIndexOrThrow(_stmt, "actorAccountName")
        val _columnIndexOfActorAccountHomePage: Int = getColumnIndexOrThrow(_stmt, "actorAccountHomePage")
        val _columnIndexOfActorStored: Int = getColumnIndexOrThrow(_stmt, "actorStored")
        val _columnIndexOfActorLastModified: Int = getColumnIndexOrThrow(_stmt, "actorLastModified")
        val _columnIndexOfActorGroupMembersLastUpdated: Int = getColumnIndexOrThrow(_stmt, "actorGroupMembersLastUpdated")
        val _columnIndexOfActorIsAnonGroup: Int = getColumnIndexOrThrow(_stmt, "actorIsAnonGroup")
        val _columnIndexOfActorObjectType: Int = getColumnIndexOrThrow(_stmt, "actorObjectType")
        val _result: XapiActorEntity?
        if (_stmt.step()) {
          val _tmpActorUid: Long
          _tmpActorUid = _stmt.getLong(_columnIndexOfActorUid)
          val _tmpActorPersonUid: Long
          _tmpActorPersonUid = _stmt.getLong(_columnIndexOfActorPersonUid)
          val _tmpActorName: String?
          if (_stmt.isNull(_columnIndexOfActorName)) {
            _tmpActorName = null
          } else {
            _tmpActorName = _stmt.getText(_columnIndexOfActorName)
          }
          val _tmpActorMbox: String?
          if (_stmt.isNull(_columnIndexOfActorMbox)) {
            _tmpActorMbox = null
          } else {
            _tmpActorMbox = _stmt.getText(_columnIndexOfActorMbox)
          }
          val _tmpActorMbox_sha1sum: String?
          if (_stmt.isNull(_columnIndexOfActorMboxSha1sum)) {
            _tmpActorMbox_sha1sum = null
          } else {
            _tmpActorMbox_sha1sum = _stmt.getText(_columnIndexOfActorMboxSha1sum)
          }
          val _tmpActorOpenid: String?
          if (_stmt.isNull(_columnIndexOfActorOpenid)) {
            _tmpActorOpenid = null
          } else {
            _tmpActorOpenid = _stmt.getText(_columnIndexOfActorOpenid)
          }
          val _tmpActorAccountName: String?
          if (_stmt.isNull(_columnIndexOfActorAccountName)) {
            _tmpActorAccountName = null
          } else {
            _tmpActorAccountName = _stmt.getText(_columnIndexOfActorAccountName)
          }
          val _tmpActorAccountHomePage: String?
          if (_stmt.isNull(_columnIndexOfActorAccountHomePage)) {
            _tmpActorAccountHomePage = null
          } else {
            _tmpActorAccountHomePage = _stmt.getText(_columnIndexOfActorAccountHomePage)
          }
          val _tmpActorStored: Instant
          val _tmp: Long?
          if (_stmt.isNull(_columnIndexOfActorStored)) {
            _tmp = null
          } else {
            _tmp = _stmt.getLong(_columnIndexOfActorStored)
          }
          val _tmp_1: Instant? = __sharedConverters.toInstant(_tmp)
          if (_tmp_1 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorStored = _tmp_1
          }
          val _tmpActorLastModified: Instant
          val _tmp_2: Long?
          if (_stmt.isNull(_columnIndexOfActorLastModified)) {
            _tmp_2 = null
          } else {
            _tmp_2 = _stmt.getLong(_columnIndexOfActorLastModified)
          }
          val _tmp_3: Instant? = __sharedConverters.toInstant(_tmp_2)
          if (_tmp_3 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorLastModified = _tmp_3
          }
          val _tmpActorGroupMembersLastUpdated: Instant
          val _tmp_4: Long?
          if (_stmt.isNull(_columnIndexOfActorGroupMembersLastUpdated)) {
            _tmp_4 = null
          } else {
            _tmp_4 = _stmt.getLong(_columnIndexOfActorGroupMembersLastUpdated)
          }
          val _tmp_5: Instant? = __sharedConverters.toInstant(_tmp_4)
          if (_tmp_5 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorGroupMembersLastUpdated = _tmp_5
          }
          val _tmpActorIsAnonGroup: Boolean
          val _tmp_6: Int
          _tmp_6 = _stmt.getLong(_columnIndexOfActorIsAnonGroup).toInt()
          _tmpActorIsAnonGroup = _tmp_6 != 0
          val _tmpActorObjectType: XapiActorEntityTypeEnum
          val _tmp_7: Int
          _tmp_7 = _stmt.getLong(_columnIndexOfActorObjectType).toInt()
          _tmpActorObjectType = __schoolTypeConverters.toActorEntityTypeEnum(_tmp_7)
          _result = XapiActorEntity(_tmpActorUid,_tmpActorPersonUid,_tmpActorName,_tmpActorMbox,_tmpActorMbox_sha1sum,_tmpActorOpenid,_tmpActorAccountName,_tmpActorAccountHomePage,_tmpActorStored,_tmpActorLastModified,_tmpActorGroupMembersLastUpdated,_tmpActorIsAnonGroup,_tmpActorObjectType)
        } else {
          _result = null
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun findByUidAndPersonUidAsync(actorUid: Long, accountPersonUid: Long): XapiActorEntity? {
    val _sql: String = """
        |
        |        SELECT XapiActorEntity.*
        |          FROM XapiActorEntity
        |         WHERE XapiActorEntity.actorUid = ?
        |           AND XapiActorEntity.actorPersonUid = ?  
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, actorUid)
        _argIndex = 2
        _stmt.bindLong(_argIndex, accountPersonUid)
        val _columnIndexOfActorUid: Int = getColumnIndexOrThrow(_stmt, "actorUid")
        val _columnIndexOfActorPersonUid: Int = getColumnIndexOrThrow(_stmt, "actorPersonUid")
        val _columnIndexOfActorName: Int = getColumnIndexOrThrow(_stmt, "actorName")
        val _columnIndexOfActorMbox: Int = getColumnIndexOrThrow(_stmt, "actorMbox")
        val _columnIndexOfActorMboxSha1sum: Int = getColumnIndexOrThrow(_stmt, "actorMbox_sha1sum")
        val _columnIndexOfActorOpenid: Int = getColumnIndexOrThrow(_stmt, "actorOpenid")
        val _columnIndexOfActorAccountName: Int = getColumnIndexOrThrow(_stmt, "actorAccountName")
        val _columnIndexOfActorAccountHomePage: Int = getColumnIndexOrThrow(_stmt, "actorAccountHomePage")
        val _columnIndexOfActorStored: Int = getColumnIndexOrThrow(_stmt, "actorStored")
        val _columnIndexOfActorLastModified: Int = getColumnIndexOrThrow(_stmt, "actorLastModified")
        val _columnIndexOfActorGroupMembersLastUpdated: Int = getColumnIndexOrThrow(_stmt, "actorGroupMembersLastUpdated")
        val _columnIndexOfActorIsAnonGroup: Int = getColumnIndexOrThrow(_stmt, "actorIsAnonGroup")
        val _columnIndexOfActorObjectType: Int = getColumnIndexOrThrow(_stmt, "actorObjectType")
        val _result: XapiActorEntity?
        if (_stmt.step()) {
          val _tmpActorUid: Long
          _tmpActorUid = _stmt.getLong(_columnIndexOfActorUid)
          val _tmpActorPersonUid: Long
          _tmpActorPersonUid = _stmt.getLong(_columnIndexOfActorPersonUid)
          val _tmpActorName: String?
          if (_stmt.isNull(_columnIndexOfActorName)) {
            _tmpActorName = null
          } else {
            _tmpActorName = _stmt.getText(_columnIndexOfActorName)
          }
          val _tmpActorMbox: String?
          if (_stmt.isNull(_columnIndexOfActorMbox)) {
            _tmpActorMbox = null
          } else {
            _tmpActorMbox = _stmt.getText(_columnIndexOfActorMbox)
          }
          val _tmpActorMbox_sha1sum: String?
          if (_stmt.isNull(_columnIndexOfActorMboxSha1sum)) {
            _tmpActorMbox_sha1sum = null
          } else {
            _tmpActorMbox_sha1sum = _stmt.getText(_columnIndexOfActorMboxSha1sum)
          }
          val _tmpActorOpenid: String?
          if (_stmt.isNull(_columnIndexOfActorOpenid)) {
            _tmpActorOpenid = null
          } else {
            _tmpActorOpenid = _stmt.getText(_columnIndexOfActorOpenid)
          }
          val _tmpActorAccountName: String?
          if (_stmt.isNull(_columnIndexOfActorAccountName)) {
            _tmpActorAccountName = null
          } else {
            _tmpActorAccountName = _stmt.getText(_columnIndexOfActorAccountName)
          }
          val _tmpActorAccountHomePage: String?
          if (_stmt.isNull(_columnIndexOfActorAccountHomePage)) {
            _tmpActorAccountHomePage = null
          } else {
            _tmpActorAccountHomePage = _stmt.getText(_columnIndexOfActorAccountHomePage)
          }
          val _tmpActorStored: Instant
          val _tmp: Long?
          if (_stmt.isNull(_columnIndexOfActorStored)) {
            _tmp = null
          } else {
            _tmp = _stmt.getLong(_columnIndexOfActorStored)
          }
          val _tmp_1: Instant? = __sharedConverters.toInstant(_tmp)
          if (_tmp_1 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorStored = _tmp_1
          }
          val _tmpActorLastModified: Instant
          val _tmp_2: Long?
          if (_stmt.isNull(_columnIndexOfActorLastModified)) {
            _tmp_2 = null
          } else {
            _tmp_2 = _stmt.getLong(_columnIndexOfActorLastModified)
          }
          val _tmp_3: Instant? = __sharedConverters.toInstant(_tmp_2)
          if (_tmp_3 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorLastModified = _tmp_3
          }
          val _tmpActorGroupMembersLastUpdated: Instant
          val _tmp_4: Long?
          if (_stmt.isNull(_columnIndexOfActorGroupMembersLastUpdated)) {
            _tmp_4 = null
          } else {
            _tmp_4 = _stmt.getLong(_columnIndexOfActorGroupMembersLastUpdated)
          }
          val _tmp_5: Instant? = __sharedConverters.toInstant(_tmp_4)
          if (_tmp_5 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorGroupMembersLastUpdated = _tmp_5
          }
          val _tmpActorIsAnonGroup: Boolean
          val _tmp_6: Int
          _tmp_6 = _stmt.getLong(_columnIndexOfActorIsAnonGroup).toInt()
          _tmpActorIsAnonGroup = _tmp_6 != 0
          val _tmpActorObjectType: XapiActorEntityTypeEnum
          val _tmp_7: Int
          _tmp_7 = _stmt.getLong(_columnIndexOfActorObjectType).toInt()
          _tmpActorObjectType = __schoolTypeConverters.toActorEntityTypeEnum(_tmp_7)
          _result = XapiActorEntity(_tmpActorUid,_tmpActorPersonUid,_tmpActorName,_tmpActorMbox,_tmpActorMbox_sha1sum,_tmpActorOpenid,_tmpActorAccountName,_tmpActorAccountHomePage,_tmpActorStored,_tmpActorLastModified,_tmpActorGroupMembersLastUpdated,_tmpActorIsAnonGroup,_tmpActorObjectType)
        } else {
          _result = null
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun findByUidList(uids: List<Long>): List<XapiActorEntity> {
    val _stringBuilder: StringBuilder = StringBuilder()
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("        SELECT XapiActorEntity.*")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("          FROM XapiActorEntity")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("         WHERE XapiActorEntity.actorUid IN (")
    val _inputSize: Int = uids.size
    appendPlaceholders(_stringBuilder, _inputSize)
    _stringBuilder.append(")")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("            OR XapiActorEntity.actorUid IN (")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("               SELECT XapiGroupMemberActorJoin.gmajMemberActorUid")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("                 FROM XapiGroupMemberActorJoin")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("                WHERE XapiGroupMemberActorJoin.gmajGroupActorUid IN (")
    val _inputSize_1: Int = uids.size
    appendPlaceholders(_stringBuilder, _inputSize_1)
    _stringBuilder.append("))")
    _stringBuilder.append("""
        |
        |""".trimMargin())
    _stringBuilder.append("    ")
    val _sql: String = _stringBuilder.toString()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        for (_item: Long in uids) {
          _stmt.bindLong(_argIndex, _item)
          _argIndex++
        }
        _argIndex = 1 + _inputSize
        for (_item_1: Long in uids) {
          _stmt.bindLong(_argIndex, _item_1)
          _argIndex++
        }
        val _columnIndexOfActorUid: Int = getColumnIndexOrThrow(_stmt, "actorUid")
        val _columnIndexOfActorPersonUid: Int = getColumnIndexOrThrow(_stmt, "actorPersonUid")
        val _columnIndexOfActorName: Int = getColumnIndexOrThrow(_stmt, "actorName")
        val _columnIndexOfActorMbox: Int = getColumnIndexOrThrow(_stmt, "actorMbox")
        val _columnIndexOfActorMboxSha1sum: Int = getColumnIndexOrThrow(_stmt, "actorMbox_sha1sum")
        val _columnIndexOfActorOpenid: Int = getColumnIndexOrThrow(_stmt, "actorOpenid")
        val _columnIndexOfActorAccountName: Int = getColumnIndexOrThrow(_stmt, "actorAccountName")
        val _columnIndexOfActorAccountHomePage: Int = getColumnIndexOrThrow(_stmt, "actorAccountHomePage")
        val _columnIndexOfActorStored: Int = getColumnIndexOrThrow(_stmt, "actorStored")
        val _columnIndexOfActorLastModified: Int = getColumnIndexOrThrow(_stmt, "actorLastModified")
        val _columnIndexOfActorGroupMembersLastUpdated: Int = getColumnIndexOrThrow(_stmt, "actorGroupMembersLastUpdated")
        val _columnIndexOfActorIsAnonGroup: Int = getColumnIndexOrThrow(_stmt, "actorIsAnonGroup")
        val _columnIndexOfActorObjectType: Int = getColumnIndexOrThrow(_stmt, "actorObjectType")
        val _result: MutableList<XapiActorEntity> = mutableListOf()
        while (_stmt.step()) {
          val _item_2: XapiActorEntity
          val _tmpActorUid: Long
          _tmpActorUid = _stmt.getLong(_columnIndexOfActorUid)
          val _tmpActorPersonUid: Long
          _tmpActorPersonUid = _stmt.getLong(_columnIndexOfActorPersonUid)
          val _tmpActorName: String?
          if (_stmt.isNull(_columnIndexOfActorName)) {
            _tmpActorName = null
          } else {
            _tmpActorName = _stmt.getText(_columnIndexOfActorName)
          }
          val _tmpActorMbox: String?
          if (_stmt.isNull(_columnIndexOfActorMbox)) {
            _tmpActorMbox = null
          } else {
            _tmpActorMbox = _stmt.getText(_columnIndexOfActorMbox)
          }
          val _tmpActorMbox_sha1sum: String?
          if (_stmt.isNull(_columnIndexOfActorMboxSha1sum)) {
            _tmpActorMbox_sha1sum = null
          } else {
            _tmpActorMbox_sha1sum = _stmt.getText(_columnIndexOfActorMboxSha1sum)
          }
          val _tmpActorOpenid: String?
          if (_stmt.isNull(_columnIndexOfActorOpenid)) {
            _tmpActorOpenid = null
          } else {
            _tmpActorOpenid = _stmt.getText(_columnIndexOfActorOpenid)
          }
          val _tmpActorAccountName: String?
          if (_stmt.isNull(_columnIndexOfActorAccountName)) {
            _tmpActorAccountName = null
          } else {
            _tmpActorAccountName = _stmt.getText(_columnIndexOfActorAccountName)
          }
          val _tmpActorAccountHomePage: String?
          if (_stmt.isNull(_columnIndexOfActorAccountHomePage)) {
            _tmpActorAccountHomePage = null
          } else {
            _tmpActorAccountHomePage = _stmt.getText(_columnIndexOfActorAccountHomePage)
          }
          val _tmpActorStored: Instant
          val _tmp: Long?
          if (_stmt.isNull(_columnIndexOfActorStored)) {
            _tmp = null
          } else {
            _tmp = _stmt.getLong(_columnIndexOfActorStored)
          }
          val _tmp_1: Instant? = __sharedConverters.toInstant(_tmp)
          if (_tmp_1 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorStored = _tmp_1
          }
          val _tmpActorLastModified: Instant
          val _tmp_2: Long?
          if (_stmt.isNull(_columnIndexOfActorLastModified)) {
            _tmp_2 = null
          } else {
            _tmp_2 = _stmt.getLong(_columnIndexOfActorLastModified)
          }
          val _tmp_3: Instant? = __sharedConverters.toInstant(_tmp_2)
          if (_tmp_3 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorLastModified = _tmp_3
          }
          val _tmpActorGroupMembersLastUpdated: Instant
          val _tmp_4: Long?
          if (_stmt.isNull(_columnIndexOfActorGroupMembersLastUpdated)) {
            _tmp_4 = null
          } else {
            _tmp_4 = _stmt.getLong(_columnIndexOfActorGroupMembersLastUpdated)
          }
          val _tmp_5: Instant? = __sharedConverters.toInstant(_tmp_4)
          if (_tmp_5 == null) {
            error("Expected NON-NULL 'kotlin.time.Instant', but it was NULL.")
          } else {
            _tmpActorGroupMembersLastUpdated = _tmp_5
          }
          val _tmpActorIsAnonGroup: Boolean
          val _tmp_6: Int
          _tmp_6 = _stmt.getLong(_columnIndexOfActorIsAnonGroup).toInt()
          _tmpActorIsAnonGroup = _tmp_6 != 0
          val _tmpActorObjectType: XapiActorEntityTypeEnum
          val _tmp_7: Int
          _tmp_7 = _stmt.getLong(_columnIndexOfActorObjectType).toInt()
          _tmpActorObjectType = __schoolTypeConverters.toActorEntityTypeEnum(_tmp_7)
          _item_2 = XapiActorEntity(_tmpActorUid,_tmpActorPersonUid,_tmpActorName,_tmpActorMbox,_tmpActorMbox_sha1sum,_tmpActorOpenid,_tmpActorAccountName,_tmpActorAccountHomePage,_tmpActorStored,_tmpActorLastModified,_tmpActorGroupMembersLastUpdated,_tmpActorIsAnonGroup,_tmpActorObjectType)
          _result.add(_item_2)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun updateIfNameChanged(
    uid: Long,
    name: String?,
    updateTime: Long,
  ) {
    val _sql: String = """
        |
        |        UPDATE XapiActorEntity
        |           SET actorName = ?,
        |               actorLastModified = ?
        |         WHERE actorUid = ?
        |           AND XapiActorEntity.actorName != ?
        |    
        """.trimMargin()
    return performSuspending(__db, false, true) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        if (name == null) {
          _stmt.bindNull(_argIndex)
        } else {
          _stmt.bindText(_argIndex, name)
        }
        _argIndex = 2
        _stmt.bindLong(_argIndex, updateTime)
        _argIndex = 3
        _stmt.bindLong(_argIndex, uid)
        _argIndex = 4
        if (name == null) {
          _stmt.bindNull(_argIndex)
        } else {
          _stmt.bindText(_argIndex, name)
        }
        _stmt.step()
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun updateGroupMembersLastUpdated(actorUid: Long, updateTime: Long) {
    val _sql: String = """
        |
        |        UPDATE XapiActorEntity
        |           SET actorGroupMembersLastUpdated = ?
        |         WHERE actorUid = ?
        |    
        """.trimMargin()
    return performSuspending(__db, false, true) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, updateTime)
        _argIndex = 2
        _stmt.bindLong(_argIndex, actorUid)
        _stmt.step()
      } finally {
        _stmt.close()
      }
    }
  }

  public companion object {
    public fun getRequiredConverters(): List<KClass<*>> = emptyList()
  }
}
