StatementBuilder

class StatementBuilder(session: CqlSession, codec: KandraCodec = KandraCodec.default, debugConfig: DebugConfig = DebugConfig(), consistencyConfig: ConsistencyConfig = ConsistencyConfig(), cacheSize: Int = 1000)

Builds BoundStatement instances for all CRUD operations.

Prepared statements are cached in a bounded LRU cache keyed by CQL string. Idempotency is set per statement type — SELECT and DELETE are idempotent; plain INSERT and collection mutations are not (to prevent duplicate writes on retry).

Constructors

Link copied to clipboard
constructor(session: CqlSession, codec: KandraCodec = KandraCodec.default, debugConfig: DebugConfig = DebugConfig(), consistencyConfig: ConsistencyConfig = ConsistencyConfig(), cacheSize: Int = 1000)

Functions

Link copied to clipboard
fun appendToCollection(schema: TableSchema, keyValues: List<Any>, columnName: String, values: Any, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun appendToCollectionSuspend(schema: TableSchema, keyValues: List<Any>, columnName: String, values: Any, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of appendToCollection (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun counterUpdate(schema: TableSchema, columnName: String, partitionKeys: Map<String, Any>, delta: Long, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun counterUpdateSuspend(schema: TableSchema, columnName: String, partitionKeys: Map<String, Any>, delta: Long, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of counterUpdate (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun deleteById(schema: TableSchema, vararg idValues: Any): BoundStatement
Link copied to clipboard
suspend fun deleteByIdSuspend(schema: TableSchema, vararg idValues: Any): BoundStatement

Suspend counterpart of deleteById (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun deleteByPartitionKeys(schema: TableSchema, vararg keyValues: Any): BoundStatement
Link copied to clipboard
fun deleteLookup(lookup: LookupTableSchema, indexValue: Any): BoundStatement
Link copied to clipboard
suspend fun deleteLookupSuspend(lookup: LookupTableSchema, indexValue: Any): BoundStatement

Suspend counterpart of deleteLookup (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun existsQuery(schema: TableSchema, whereCql: String, values: List<Any?>): BoundStatement
Link copied to clipboard
fun insertLookup(schema: TableSchema, lookup: LookupTableSchema, entity: Any): BoundStatement

schema is only needed to source the entity's cached io.kandra.core.schema.EntityReflection property map (resolved once at io.kandra.core.SchemaRegistry.register time) — entity is always an instance of schema's entityClass.

Link copied to clipboard
suspend fun insertLookupSuspend(schema: TableSchema, lookup: LookupTableSchema, entity: Any): BoundStatement

Suspend counterpart of insertLookup (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun insertPrimary(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, ifNotExists: Boolean = false, timestampMicros: Long? = null, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun insertPrimarySuspend(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, ifNotExists: Boolean = false, timestampMicros: Long? = null, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of insertPrimary (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun insertPrimaryWithNulls(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, ifNotExists: Boolean = false, timestampMicros: Long? = null, consistency: KandraConsistency? = null): BoundStatement

Same as insertPrimary but binds null as actual null (creates tombstones). Use when the caller explicitly wants to clear optional columns.

Link copied to clipboard
suspend fun insertPrimaryWithNullsSuspend(schema: TableSchema, entity: Any, ttlSeconds: Int? = null, ifNotExists: Boolean = false, timestampMicros: Long? = null, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of insertPrimaryWithNulls (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun removeFromCollection(schema: TableSchema, keyValues: List<Any>, columnName: String, values: Any, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun removeFromCollectionSuspend(schema: TableSchema, keyValues: List<Any>, columnName: String, values: Any, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of removeFromCollection (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun selectById(schema: TableSchema, vararg idValues: Any, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun selectByIdSuspend(schema: TableSchema, vararg idValues: Any, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of selectById (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun selectByLookup(schema: TableSchema, lookup: LookupTableSchema, value: Any, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun selectByLookupSuspend(schema: TableSchema, lookup: LookupTableSchema, value: Any, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of selectByLookup (GH #27 / ISS-049) — see prepareSuspend.

Link copied to clipboard
fun selectByPartitionKeyIn(schema: TableSchema, ids: List<Any>, consistency: KandraConsistency? = null): BoundStatement
Link copied to clipboard
suspend fun selectByPartitionKeyInSuspend(schema: TableSchema, ids: List<Any>, consistency: KandraConsistency? = null): BoundStatement

Suspend counterpart of selectByPartitionKeyIn (GH #27 / ISS-049) — see prepareSuspend.