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

import androidx.room.EntityInsertAdapter
import androidx.room.RoomDatabase
import androidx.room.coroutines.createFlow
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 kotlinx.coroutines.flow.Flow
import world.respect.datalayer.db.school.xapi.entities.XapiStatementEntityJson

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

  private val __insertAdapterOfXapiStatementEntityJson: EntityInsertAdapter<XapiStatementEntityJson>
  init {
    this.__db = __db
    this.__insertAdapterOfXapiStatementEntityJson = object : EntityInsertAdapter<XapiStatementEntityJson>() {
      protected override fun createQuery(): String = "INSERT OR IGNORE INTO `XapiStatementEntityJson` (`stmtJsonIdHi`,`stmtJsonIdLo`,`fullStatement`) VALUES (?,?,?)"

      protected override fun bind(statement: SQLiteStatement, entity: XapiStatementEntityJson) {
        statement.bindLong(1, entity.stmtJsonIdHi)
        statement.bindLong(2, entity.stmtJsonIdLo)
        statement.bindText(3, entity.fullStatement)
      }
    }
  }

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

  public override suspend fun list(
    statementIdHi: Long,
    statementIdLo: Long,
    voidedStatementIdHi: Long,
    voidedStatementIdLo: Long,
    agentUid: Long,
    verbUid: Long,
    activityUid: Long,
    relatedAgents: Boolean,
    relatedActivities: Boolean,
    since: Long,
    until: Long,
    ascending: Boolean,
    limit: Int,
    authenticatedPersonUidNum: Long,
    authenticatedActorUid: Long,
    appListingVerbUid: Long,
  ): List<XapiStatementEntityJson> {
    val _sql: String = """
        |
        |            -- Get a list of all the actors that should be considered as related to agent parameter
        |            -- Eg the actor uid itself and any group members
        |          WITH AgentActorUids(uid) AS
        |               (SELECT ? AS uid
        |                 UNION
        |                SELECT XapiGroupMemberActorJoin.gmajGroupActorUid AS uid
        |                  FROM XapiGroupMemberActorJoin
        |                 WHERE ? != 0 
        |                   AND XapiGroupMemberActorJoin.gmajMemberActorUid = ?)
        |            
        |            
        |        SELECT XapiStatementEntityJson.*
        |          FROM XapiStatementEntity
        |               JOIN XapiStatementEntityJson
        |                    ON (    XapiStatementEntityJson.stmtJsonIdHi = XapiStatementEntity.statementIdHi
        |                        AND XapiStatementEntityJson.stmtJsonIdLo = XapiStatementEntity.statementIdLo)
        |               LEFT JOIN XapiStatementEntity AS SubStatementEntity
        |                    ON (    XapiStatementEntity.statementObjectType = 4
        |                        AND SubStatementEntity.statementIdHi = XapiStatementEntity.statementObjectUid1
        |                        AND SubStatementEntity.statementIdLo = XapiStatementEntity.statementObjectUid2)
        |         WHERE (   (? = 0 AND ? = 0) 
        |                OR (     XapiStatementEntity.statementIdHi = ? 
        |                     AND XapiStatementEntity.statementIdLo = ?))
        |           AND (   (? = 0 AND ? = 0)
        |                OR (     XapiStatementEntity.statementIdHi = ? 
        |                     AND XapiStatementEntity.statementIdLo = ?
        |                     AND XapiStatementEntity.stmtVoid))
        |           AND (? = -9223372036854775808 OR XapiStatementEntity.stored > ?)
        |           AND (? = 9223372036854775807 OR XapiStatementEntity.stored <= ?)
        |           -- Handle agent parameter
        |           AND (    ? = 0 
        |                  OR (    XapiStatementEntity.statementActorUid IN 
        |                          (SELECT uid FROM AgentActorUids))
        |                  OR (    (    XapiStatementEntity.statementObjectType = 1
        |                            OR XapiStatementEntity.statementObjectType = 2)
        |                      AND (XapiStatementEntity.statementObjectUid1 IN (SELECT uid FROM AgentActorUids)))
        |                  -- Handle related agents        
        |                  OR (    ? 
        |                      AND (    XapiStatementEntity.authorityActorUid IN (SELECT uid FROM AgentActorUids)
        |                            OR XapiStatementEntity.contextTeamActorUid IN (SELECT uid FROM AgentActorUids)
        |                            OR XapiStatementEntity.contextInstructorActorUid IN (SELECT uid FROM AgentActorUids)
        |                            -- check substatement if applicable
        |                            OR (     SubStatementEntity.statementActorUid IS NOT NULL
        |                                AND (    SubStatementEntity.statementActorUid IN (SELECT uid FROM AgentActorUids)
        |                                      OR (     (   SubStatementEntity.statementObjectType = 1
        |                                                OR SubStatementEntity.statementObjectType = 2)
        |                                           AND (SubStatementEntity.statementObjectUid1 IN (SELECT uid FROM AgentActorUids)))
        |                                           
        |                                      OR (SubStatementEntity.authorityActorUid IN (SELECT uid FROM AgentActorUids))
        |                                      OR (SubStatementEntity.contextTeamActorUid IN (SELECT uid FROM AgentActorUids))
        |                                      OR (SubStatementEntity.contextInstructorActorUid IN (SELECT uid FROM AgentActorUids))  
        |                                    )
        |                               )       
        |                          )
        |                     )
        |               )
        |           AND (? = 0 OR XapiStatementEntity.statementVerbUid = ?)
        |               -- Handle activity parameter
        |           AND (      ? = 0
        |                   OR (     XapiStatementEntity.statementObjectType = 5
        |                       AND XapiStatementEntity.statementObjectUid1 = ?)
        |                   OR (     ?    
        |                        AND (    -- As per spec check if substatement activity matches when relatedActivities is set  
        |                                 (     SubStatementEntity.statementObjectType = 5 
        |                                   AND SubStatementEntity.statementObjectUid1 = ?)
        |                                 -- As per spec check if activity uid is part included in context activities.   
        |                               OR (? IN 
        |                                   (SELECT XapiStatementContextActivityJoin.scajToActivityUid
        |                                      FROM XapiStatementContextActivityJoin
        |                                     WHERE (    XapiStatementContextActivityJoin.scajFromStatementIdHi = XapiStatementEntity.statementIdHi
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdLo = XapiStatementEntity.statementIdLo)
        |                                        OR (    SubStatementEntity.statementIdHi IS NOT NULL 
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdHi = SubStatementEntity.statementIdHi
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdLo = SubStatementEntity.statementIdLo)     
        |                                   )
        |                                  )    
        |                            )
        |                      ) 
        |               )          
        |           AND NOT XapiStatementEntity.isSubStatement
        |           AND (    NOT XapiStatementEntity.stmtVoid
        |                 OR (? != 0 AND ? != 0))
        |           AND 
        |            (   (SELECT EXISTS(
        |                        SELECT 1
        |                          FROM PersonRoleEntity
        |                         WHERE PersonRoleEntity.prPersonGuidHash = ?
        |                           AND (     PersonRoleEntity.prRoleEnum = 4
        |                                  OR PersonRoleEntity.prRoleEnum = 3
        |                                  OR PersonRoleEntity.prRoleEnum = 1)))
        |                 OR (? = XapiStatementEntity.statementActorUid)
        |                 OR (     ? = XapiStatementEntity.statementObjectUid1
        |                      AND XapiStatementEntity.statementObjectType = 1)
        |                 OR (     XapiStatementEntity.statementVerbUid = ?)     
        |                 OR (? IN 
        |                     (SELECT XapiGroupMemberActorJoin.gmajMemberActorUid
        |                        FROM XapiGroupMemberActorJoin
        |                       WHERE XapiGroupMemberActorJoin.gmajGroupActorUid = XapiStatementEntity.statementActorUid
        |                          OR (     XapiGroupMemberActorJoin.gmajGroupActorUid = XapiStatementEntity.statementObjectUid1
        |                               AND XapiStatementEntity.statementObjectType = 2))
        |                    )          
        |               )
        |              
        |      ORDER BY CASE(?) WHEN 1 THEN XapiStatementEntity.stored END ASC,
        |               CASE(?) WHEN 0 THEN XapiStatementEntity.stored END DESC
        |         LIMIT ?
        |        
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 2
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 3
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 4
        _stmt.bindLong(_argIndex, statementIdHi)
        _argIndex = 5
        _stmt.bindLong(_argIndex, statementIdLo)
        _argIndex = 6
        _stmt.bindLong(_argIndex, statementIdHi)
        _argIndex = 7
        _stmt.bindLong(_argIndex, statementIdLo)
        _argIndex = 8
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 9
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 10
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 11
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 12
        _stmt.bindLong(_argIndex, since)
        _argIndex = 13
        _stmt.bindLong(_argIndex, since)
        _argIndex = 14
        _stmt.bindLong(_argIndex, until)
        _argIndex = 15
        _stmt.bindLong(_argIndex, until)
        _argIndex = 16
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 17
        val _tmp: Int = if (relatedAgents) 1 else 0
        _stmt.bindLong(_argIndex, _tmp.toLong())
        _argIndex = 18
        _stmt.bindLong(_argIndex, verbUid)
        _argIndex = 19
        _stmt.bindLong(_argIndex, verbUid)
        _argIndex = 20
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 21
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 22
        val _tmp_1: Int = if (relatedActivities) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_1.toLong())
        _argIndex = 23
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 24
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 25
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 26
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 27
        _stmt.bindLong(_argIndex, authenticatedPersonUidNum)
        _argIndex = 28
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 29
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 30
        _stmt.bindLong(_argIndex, appListingVerbUid)
        _argIndex = 31
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 32
        val _tmp_2: Int = if (ascending) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_2.toLong())
        _argIndex = 33
        val _tmp_3: Int = if (ascending) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_3.toLong())
        _argIndex = 34
        _stmt.bindLong(_argIndex, limit.toLong())
        val _columnIndexOfStmtJsonIdHi: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdHi")
        val _columnIndexOfStmtJsonIdLo: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdLo")
        val _columnIndexOfFullStatement: Int = getColumnIndexOrThrow(_stmt, "fullStatement")
        val _result: MutableList<XapiStatementEntityJson> = mutableListOf()
        while (_stmt.step()) {
          val _item: XapiStatementEntityJson
          val _tmpStmtJsonIdHi: Long
          _tmpStmtJsonIdHi = _stmt.getLong(_columnIndexOfStmtJsonIdHi)
          val _tmpStmtJsonIdLo: Long
          _tmpStmtJsonIdLo = _stmt.getLong(_columnIndexOfStmtJsonIdLo)
          val _tmpFullStatement: String
          _tmpFullStatement = _stmt.getText(_columnIndexOfFullStatement)
          _item = XapiStatementEntityJson(_tmpStmtJsonIdHi,_tmpStmtJsonIdLo,_tmpFullStatement)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override fun listAsFlow(
    statementIdHi: Long,
    statementIdLo: Long,
    voidedStatementIdHi: Long,
    voidedStatementIdLo: Long,
    agentUid: Long,
    verbUid: Long,
    activityUid: Long,
    relatedAgents: Boolean,
    relatedActivities: Boolean,
    since: Long,
    until: Long,
    ascending: Boolean,
    limit: Int,
    authenticatedPersonUidNum: Long,
    authenticatedActorUid: Long,
    appListingVerbUid: Long,
  ): Flow<List<XapiStatementEntityJson>> {
    val _sql: String = """
        |
        |            -- Get a list of all the actors that should be considered as related to agent parameter
        |            -- Eg the actor uid itself and any group members
        |          WITH AgentActorUids(uid) AS
        |               (SELECT ? AS uid
        |                 UNION
        |                SELECT XapiGroupMemberActorJoin.gmajGroupActorUid AS uid
        |                  FROM XapiGroupMemberActorJoin
        |                 WHERE ? != 0 
        |                   AND XapiGroupMemberActorJoin.gmajMemberActorUid = ?)
        |            
        |            
        |        SELECT XapiStatementEntityJson.*
        |          FROM XapiStatementEntity
        |               JOIN XapiStatementEntityJson
        |                    ON (    XapiStatementEntityJson.stmtJsonIdHi = XapiStatementEntity.statementIdHi
        |                        AND XapiStatementEntityJson.stmtJsonIdLo = XapiStatementEntity.statementIdLo)
        |               LEFT JOIN XapiStatementEntity AS SubStatementEntity
        |                    ON (    XapiStatementEntity.statementObjectType = 4
        |                        AND SubStatementEntity.statementIdHi = XapiStatementEntity.statementObjectUid1
        |                        AND SubStatementEntity.statementIdLo = XapiStatementEntity.statementObjectUid2)
        |         WHERE (   (? = 0 AND ? = 0) 
        |                OR (     XapiStatementEntity.statementIdHi = ? 
        |                     AND XapiStatementEntity.statementIdLo = ?))
        |           AND (   (? = 0 AND ? = 0)
        |                OR (     XapiStatementEntity.statementIdHi = ? 
        |                     AND XapiStatementEntity.statementIdLo = ?
        |                     AND XapiStatementEntity.stmtVoid))
        |           AND (? = -9223372036854775808 OR XapiStatementEntity.stored > ?)
        |           AND (? = 9223372036854775807 OR XapiStatementEntity.stored <= ?)
        |           -- Handle agent parameter
        |           AND (    ? = 0 
        |                  OR (    XapiStatementEntity.statementActorUid IN 
        |                          (SELECT uid FROM AgentActorUids))
        |                  OR (    (    XapiStatementEntity.statementObjectType = 1
        |                            OR XapiStatementEntity.statementObjectType = 2)
        |                      AND (XapiStatementEntity.statementObjectUid1 IN (SELECT uid FROM AgentActorUids)))
        |                  -- Handle related agents        
        |                  OR (    ? 
        |                      AND (    XapiStatementEntity.authorityActorUid IN (SELECT uid FROM AgentActorUids)
        |                            OR XapiStatementEntity.contextTeamActorUid IN (SELECT uid FROM AgentActorUids)
        |                            OR XapiStatementEntity.contextInstructorActorUid IN (SELECT uid FROM AgentActorUids)
        |                            -- check substatement if applicable
        |                            OR (     SubStatementEntity.statementActorUid IS NOT NULL
        |                                AND (    SubStatementEntity.statementActorUid IN (SELECT uid FROM AgentActorUids)
        |                                      OR (     (   SubStatementEntity.statementObjectType = 1
        |                                                OR SubStatementEntity.statementObjectType = 2)
        |                                           AND (SubStatementEntity.statementObjectUid1 IN (SELECT uid FROM AgentActorUids)))
        |                                           
        |                                      OR (SubStatementEntity.authorityActorUid IN (SELECT uid FROM AgentActorUids))
        |                                      OR (SubStatementEntity.contextTeamActorUid IN (SELECT uid FROM AgentActorUids))
        |                                      OR (SubStatementEntity.contextInstructorActorUid IN (SELECT uid FROM AgentActorUids))  
        |                                    )
        |                               )       
        |                          )
        |                     )
        |               )
        |           AND (? = 0 OR XapiStatementEntity.statementVerbUid = ?)
        |               -- Handle activity parameter
        |           AND (      ? = 0
        |                   OR (     XapiStatementEntity.statementObjectType = 5
        |                       AND XapiStatementEntity.statementObjectUid1 = ?)
        |                   OR (     ?    
        |                        AND (    -- As per spec check if substatement activity matches when relatedActivities is set  
        |                                 (     SubStatementEntity.statementObjectType = 5 
        |                                   AND SubStatementEntity.statementObjectUid1 = ?)
        |                                 -- As per spec check if activity uid is part included in context activities.   
        |                               OR (? IN 
        |                                   (SELECT XapiStatementContextActivityJoin.scajToActivityUid
        |                                      FROM XapiStatementContextActivityJoin
        |                                     WHERE (    XapiStatementContextActivityJoin.scajFromStatementIdHi = XapiStatementEntity.statementIdHi
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdLo = XapiStatementEntity.statementIdLo)
        |                                        OR (    SubStatementEntity.statementIdHi IS NOT NULL 
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdHi = SubStatementEntity.statementIdHi
        |                                            AND XapiStatementContextActivityJoin.scajFromStatementIdLo = SubStatementEntity.statementIdLo)     
        |                                   )
        |                                  )    
        |                            )
        |                      ) 
        |               )          
        |           AND NOT XapiStatementEntity.isSubStatement
        |           AND (    NOT XapiStatementEntity.stmtVoid
        |                 OR (? != 0 AND ? != 0))
        |           AND 
        |            (   (SELECT EXISTS(
        |                        SELECT 1
        |                          FROM PersonRoleEntity
        |                         WHERE PersonRoleEntity.prPersonGuidHash = ?
        |                           AND (     PersonRoleEntity.prRoleEnum = 4
        |                                  OR PersonRoleEntity.prRoleEnum = 3
        |                                  OR PersonRoleEntity.prRoleEnum = 1)))
        |                 OR (? = XapiStatementEntity.statementActorUid)
        |                 OR (     ? = XapiStatementEntity.statementObjectUid1
        |                      AND XapiStatementEntity.statementObjectType = 1)
        |                 OR (     XapiStatementEntity.statementVerbUid = ?)     
        |                 OR (? IN 
        |                     (SELECT XapiGroupMemberActorJoin.gmajMemberActorUid
        |                        FROM XapiGroupMemberActorJoin
        |                       WHERE XapiGroupMemberActorJoin.gmajGroupActorUid = XapiStatementEntity.statementActorUid
        |                          OR (     XapiGroupMemberActorJoin.gmajGroupActorUid = XapiStatementEntity.statementObjectUid1
        |                               AND XapiStatementEntity.statementObjectType = 2))
        |                    )          
        |               )
        |              
        |      ORDER BY CASE(?) WHEN 1 THEN XapiStatementEntity.stored END ASC,
        |               CASE(?) WHEN 0 THEN XapiStatementEntity.stored END DESC
        |         LIMIT ?
        |        
        """.trimMargin()
    return createFlow(__db, false, arrayOf("XapiGroupMemberActorJoin", "XapiStatementEntity", "XapiStatementEntityJson", "XapiStatementContextActivityJoin", "PersonRoleEntity")) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 2
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 3
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 4
        _stmt.bindLong(_argIndex, statementIdHi)
        _argIndex = 5
        _stmt.bindLong(_argIndex, statementIdLo)
        _argIndex = 6
        _stmt.bindLong(_argIndex, statementIdHi)
        _argIndex = 7
        _stmt.bindLong(_argIndex, statementIdLo)
        _argIndex = 8
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 9
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 10
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 11
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 12
        _stmt.bindLong(_argIndex, since)
        _argIndex = 13
        _stmt.bindLong(_argIndex, since)
        _argIndex = 14
        _stmt.bindLong(_argIndex, until)
        _argIndex = 15
        _stmt.bindLong(_argIndex, until)
        _argIndex = 16
        _stmt.bindLong(_argIndex, agentUid)
        _argIndex = 17
        val _tmp: Int = if (relatedAgents) 1 else 0
        _stmt.bindLong(_argIndex, _tmp.toLong())
        _argIndex = 18
        _stmt.bindLong(_argIndex, verbUid)
        _argIndex = 19
        _stmt.bindLong(_argIndex, verbUid)
        _argIndex = 20
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 21
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 22
        val _tmp_1: Int = if (relatedActivities) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_1.toLong())
        _argIndex = 23
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 24
        _stmt.bindLong(_argIndex, activityUid)
        _argIndex = 25
        _stmt.bindLong(_argIndex, voidedStatementIdHi)
        _argIndex = 26
        _stmt.bindLong(_argIndex, voidedStatementIdLo)
        _argIndex = 27
        _stmt.bindLong(_argIndex, authenticatedPersonUidNum)
        _argIndex = 28
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 29
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 30
        _stmt.bindLong(_argIndex, appListingVerbUid)
        _argIndex = 31
        _stmt.bindLong(_argIndex, authenticatedActorUid)
        _argIndex = 32
        val _tmp_2: Int = if (ascending) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_2.toLong())
        _argIndex = 33
        val _tmp_3: Int = if (ascending) 1 else 0
        _stmt.bindLong(_argIndex, _tmp_3.toLong())
        _argIndex = 34
        _stmt.bindLong(_argIndex, limit.toLong())
        val _columnIndexOfStmtJsonIdHi: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdHi")
        val _columnIndexOfStmtJsonIdLo: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdLo")
        val _columnIndexOfFullStatement: Int = getColumnIndexOrThrow(_stmt, "fullStatement")
        val _result: MutableList<XapiStatementEntityJson> = mutableListOf()
        while (_stmt.step()) {
          val _item: XapiStatementEntityJson
          val _tmpStmtJsonIdHi: Long
          _tmpStmtJsonIdHi = _stmt.getLong(_columnIndexOfStmtJsonIdHi)
          val _tmpStmtJsonIdLo: Long
          _tmpStmtJsonIdLo = _stmt.getLong(_columnIndexOfStmtJsonIdLo)
          val _tmpFullStatement: String
          _tmpFullStatement = _stmt.getText(_columnIndexOfFullStatement)
          _item = XapiStatementEntityJson(_tmpStmtJsonIdHi,_tmpStmtJsonIdLo,_tmpFullStatement)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

  public override suspend fun getStatements(stmtJsonIdHi: Long, stmtJsonIdLo: Long): List<XapiStatementEntityJson> {
    val _sql: String = """
        |
        |        SELECT XapiStatementEntityJson.*
        |          FROM XapiStatementEntityJson
        |         WHERE (    (? = 0 AND ? = 0) 
        |                 OR (stmtJsonIdHi = ? AND stmtJsonIdLo = ?))
        |                  
        |    
        """.trimMargin()
    return performSuspending(__db, true, false) { _connection ->
      val _stmt: SQLiteStatement = _connection.prepare(_sql)
      try {
        var _argIndex: Int = 1
        _stmt.bindLong(_argIndex, stmtJsonIdHi)
        _argIndex = 2
        _stmt.bindLong(_argIndex, stmtJsonIdLo)
        _argIndex = 3
        _stmt.bindLong(_argIndex, stmtJsonIdHi)
        _argIndex = 4
        _stmt.bindLong(_argIndex, stmtJsonIdLo)
        val _columnIndexOfStmtJsonIdHi: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdHi")
        val _columnIndexOfStmtJsonIdLo: Int = getColumnIndexOrThrow(_stmt, "stmtJsonIdLo")
        val _columnIndexOfFullStatement: Int = getColumnIndexOrThrow(_stmt, "fullStatement")
        val _result: MutableList<XapiStatementEntityJson> = mutableListOf()
        while (_stmt.step()) {
          val _item: XapiStatementEntityJson
          val _tmpStmtJsonIdHi: Long
          _tmpStmtJsonIdHi = _stmt.getLong(_columnIndexOfStmtJsonIdHi)
          val _tmpStmtJsonIdLo: Long
          _tmpStmtJsonIdLo = _stmt.getLong(_columnIndexOfStmtJsonIdLo)
          val _tmpFullStatement: String
          _tmpFullStatement = _stmt.getText(_columnIndexOfFullStatement)
          _item = XapiStatementEntityJson(_tmpStmtJsonIdHi,_tmpStmtJsonIdLo,_tmpFullStatement)
          _result.add(_item)
        }
        _result
      } finally {
        _stmt.close()
      }
    }
  }

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