← Back to Stormify Documentation

CRUDTable

interface CRUDTable

Mixin interface that adds create, update, and delete convenience methods directly on an entity class, delegating to the entity's attached Stormify instance (if any) or the library-wide default.

Each call routes through the ambient-transaction registry, so when invoked from inside a stormify.transaction { } block the work runs on the transaction's connection and participates in its commit/rollback. Outside a transaction each call runs in auto-commit on a fresh pool connection.

class User(var id: Int = 0, var name: String = "") : CRUDTable

stormify.asDefault()
stormify.transaction {
User(name = "Alice").create() // uses tx connection
User(1, "Bob").update() // same tx
}

User(2, "Carol").create() // auto-commit on a pool connection

Especially useful from Java, where Kotlin extension functions are not available — implementing this interface exposes the CRUD methods as plain instance methods that the Java compiler recognises.

Functions

Link copied to clipboard
open fun create()

Inserts this entity into the database.

Link copied to clipboard
open fun delete()

Deletes this entity from the database based on its primary key.

Link copied to clipboard
open fun update()

Updates this entity in the database based on its primary key.