← Back to Stormify Documentation

StormifyJ

class StormifyJ(val stormify: Stormify)

Entry point for Stormify from Java code. Provides CRUD operations, raw SQL queries, stored procedure calls, and transaction management against a javax.sql.DataSource.

StormifyJ stormify = new StormifyJ(hikariDataSource);
stormify.asDefault();
User u = stormify.findById(User.class, 1);

From Kotlin code, use Stormify directly; the two share their instances through stormify and the StormifyJ constructor that takes a Stormify.

Constructors

Link copied to clipboard
constructor(stormify: Stormify)
constructor(dataSource: DataSource, vararg registrars: EntityRegistrar)

Creates the Stormify instance of dataSource, registering registrars.

constructor(jdbcDataSource: DataSource, vararg registrars: EntityRegistrar)

Convenience constructor that accepts any javax.sql.DataSource (HikariCP, plain JDBC driver, etc.).

constructor(dataSource: DataSource)

Single-argument convenience constructor. Exists primarily so Spring XML <constructor-arg ref="dataSource"/> (and similar DI containers that resolve constructors by arity) can pick an unambiguous one-arg match.

constructor(jdbcDataSource: DataSource)

Single-argument javax.sql.DataSource overload — see the primary one-arg constructor for the rationale.

Types

Link copied to clipboard
object Companion

Access to the library-wide default instance from Java.

Properties

Link copied to clipboard

Rows buffered by the driver per round trip in streaming reads. See Stormify.cursorFetchSize.

Link copied to clipboard

What a reference to a missing row does. See Stormify.danglingReferences.

Link copied to clipboard
val dataSource: DataSource

The data source this instance runs its queries on. See Stormify.dataSource.

Link copied to clipboard

Whether update writes only the changed columns. See Stormify.dynamicUpdate.

Link copied to clipboard

Filter syntax of the facets of lists attached to this instance. See Stormify.filterSyntax.

Link copied to clipboard

Default input parser for facet filter values of lists attached to this instance, or null for none. See Stormify.inputParser.

Link copied to clipboard
var logger: Logger

The logger used by the underlying Stormify instance.

Link copied to clipboard
Link copied to clipboard

The SQL dialect, auto-detected from the data source on first access. Set it manually when detection cannot see the real database, for example behind a proxy or a pool that hides the driver metadata. See Stormify.sqlDialect.

Link copied to clipboard

The Stormify instance this wrapper works on.

Link copied to clipboard

Text folding of case-insensitive facet filters. See Stormify.textFolding.

Link copied to clipboard

Policy for unmatched result-set columns. See Stormify.unmatchedColumnPolicy.

Functions

Link copied to clipboard
Link copied to clipboard

Registers the underlying Stormify instance as the library-wide default, the one getDefault wraps. Returns this wrapper for fluent chaining.

Link copied to clipboard
fun <T : StormifyEntity> attach(target: T): T

Attaches the underlying Stormify instance to the entity target, so it lazy-loads and writes through this instance. Entities this instance reads are attached already. Returns target for fluent chaining.

Link copied to clipboard
fun <T : Any> create(item: T): T

Inserts item into its mapped table and returns the (possibly key-populated) entity.

fun <T : Any> create(items: Collection<T>): List<T>

Batch INSERT of items in a single round trip.

Link copied to clipboard
fun delete(deletedItem: Any)

DELETE's the row corresponding to deletedItem using its primary key.

fun <T : Any> delete(items: Collection<T>)

Batch DELETE of items.

Link copied to clipboard
fun executeUpdate(query: String, vararg params: Any?): Int

Executes an INSERT / UPDATE / DELETE and returns the affected row count.

Link copied to clipboard
fun <T : Any> findAll(baseClass: Class<T>, whereClause: String = "", vararg arguments: Any?): List<T>

Convenience over read for SELECT * FROM <table> <whereClause>.

Link copied to clipboard
fun <T : Any> findById(baseClass: Class<T>, id: Any): T?

Looks up a single row of baseClass by its primary key id. Returns null if not found.

Link copied to clipboard
fun <M : Any, T : Any> getDetails(parent: M, detailsClass: Class<T>, propertyName: String? = null): List<T>

Returns the detail rows of type detailsClass that reference parent. Use propertyName to disambiguate when the detail class has multiple foreign keys pointing at the same parent type.

fun <M : Any, T : Any> getDetails(parent: M, detailsClass: Class<T>, referenceField: ReferencePath): List<T>

Type-safe variant of getDetails that accepts an annotation-processor-generated reference path (e.g. Tables.AuditEntry_.createdBy) instead of a string. The compiler guarantees the referenced property exists on the child type, so typos and renames surface at build time rather than on first query.

Link copied to clipboard
fun <T : Any> getTableInfo(baseClass: Class<T>): TableInfo<T>

Returns the TableInfo metadata for baseClass, building it on first access.

Link copied to clipboard
fun <T : Any> pagedList(entityClass: Class<T>): PagedList<T>

Creates a PagedList of entityClass working on this instance, ready to be configured.

Link copied to clipboard
fun <T : Any> pagedQuery(entityClass: Class<T>): PagedQuery<T>

Creates a PagedQuery of entityClass working on this instance, ready to be configured.

Link copied to clipboard
fun procedure(name: String, vararg args: Any?)

Invokes the stored procedure name with args. Output and bidirectional parameters should be passed as Sp.Out / Sp.InOut instances; all other values are auto-wrapped as IN.

Link copied to clipboard
fun <T : Any> read(baseClass: Class<T>, query: String, vararg params: Any?): List<T>

Executes a SELECT and returns the rows as a list of baseClass instances.

fun <T : Any> read(baseClass: Class<T>, query: String, customFields: Map<String, Consumer<Any?>>, vararg params: Any?): List<T>

Executes a SELECT and returns the rows, capturing values from columns named in customFields (e.g. COUNT(*) OVER () AS __total) via the supplied consumers — those columns are not mapped onto the entity. Column names are matched case-insensitively.

Link copied to clipboard
fun <T : Any> readCursor(baseClass: Class<T>, query: String, consumer: Consumer<T>, vararg params: Any?): Int

Executes a SELECT and streams each row to consumer — avoids materializing the full result.

fun <T : Any> readCursor(baseClass: Class<T>, query: String, fetchSize: Int, consumer: Consumer<T>, vararg params: Any?): Int

readCursor fetching fetchSize rows per round trip instead of cursorFetchSize; 0 reads the whole result without a cursor.

fun <T : Any> readCursor(baseClass: Class<T>, query: String, customFields: Map<String, Consumer<Any?>>, consumer: Consumer<T>, vararg params: Any?): Int

Streaming variant that captures values from columns named in customFields via the supplied consumers instead of mapping them onto the entity. See the list-returning read overload for the capture semantics.

Link copied to clipboard
fun <T : Any> readOne(baseClass: Class<T>, query: String, vararg params: Any?): T?

Executes a SELECT and returns the first row as a baseClass instance, or null if empty.

Link copied to clipboard
fun readRows(query: String, vararg params: Any?): List<Array<Any?>>

Executes a SELECT and returns every row as an array of its column values, by position, so columns with the same label all come back. See Stormify.readRows.

Link copied to clipboard
fun readRowsCursor(query: String, consumer: Consumer<Array<Any?>>, vararg params: Any?): Int

Streams every row to consumer as an array of its column values. See Stormify.readRowsCursor.

fun readRowsCursor(query: String, fetchSize: Int, consumer: Consumer<Array<Any?>>, vararg params: Any?): Int

readRowsCursor fetching fetchSize rows per round trip instead of cursorFetchSize; 0 reads the whole result without a cursor. See Stormify.readRowsCursor.

Link copied to clipboard
fun <T : Any> refresh(entity: T): T

Refreshes entity from the database by its primary key.

Link copied to clipboard
Link copied to clipboard
fun transaction(block: Runnable)

Runs block inside a database transaction. Commits on return, rolls back on any thrown exception. Inside the block, all CRUD/query calls on this wrapper (e.g. stormify.create(user)) transparently run on the transaction's connection via the ambient transaction registry. Nested calls to this method become savepoints automatically.

fun <R> transaction(block: Supplier<R>): R

Returning variant of transaction — see that method for lifecycle semantics.

Link copied to clipboard
fun <T : Any> update(updatedItem: T): T

UPDATE's the row corresponding to updatedItem using its primary key.

fun <T : Any> update(items: Collection<T>): List<T>

Batch UPDATE of items.