Skip to content

//misk-hibernate/misk.hibernate

Package-level declarations

Types

Name Summary
AggregationType [jvm]
enum AggregationType : Enum<AggregationType>
Available aggregations which can be applied to a single value Select query, or a Property of a projection.
BindPolicy [jvm]
enum BindPolicy : Enum<BindPolicy>
Control how we register listeners.
Check [jvm]
typealias Check = misk.jdbc.Check
Constraint [jvm]
annotation class Constraint(val path: String, val operator: Operator = Operator.EQ)
Annotates a function on a Query interface to indicate which column (or path of columns) it constrains and using which Operator.
DbChild [jvm]
interface DbChild<R : DbRoot<R>, T : DbChild<R, T>> : DbSharded<R, T>
Marker interface for sharded entities that stay with their root inside an entity group. Entity group children will always stay inside the same shard regardless of shard splits and so on. That means transactions inside an entity group is always safe. A typical sharding strategy has a DbCustomer as a root and all of the entities that belong to that customer as children.
DbEntity [jvm]
interface DbEntity<T : DbEntity<T>>
Marker interface for persistent entities. Ensures that only persistent entities can be passed into Session methods.
DbRoot [jvm]
interface DbRoot<T : DbRoot<T>> : DbSharded<T, T>
Marker interface for sharded entity group roots. Entity group roots are spread out across shards they can also have children in the form of DbChild subclasses that always stay in the same shard as their roots. A typical root is for example DbCustomer.
DbSharded [jvm]
interface DbSharded<R : DbRoot<R>, T : DbSharded<R, T>> : DbEntity<T>
Marker interface for sharded persistent entities. Do not subclass directly, instead subclass either DbRoot for entity group roots or DbChild for entity group children.
DbTimestampedEntity [jvm]
interface DbTimestampedEntity
This complements DbEntity for entities that keep updated_at and created_at timestamps.
DbUnsharded [jvm]
interface DbUnsharded<T : DbUnsharded<T>> : DbEntity<T>
Marker interface for persistent entities that have a bounded growth and do not require sharding.
Fetch [jvm]
annotation class Fetch(val path: String = "", val joinType: JoinType = LEFT, val forProjection: Boolean = false)
Annotates a function on a Query interface to specify that the association at the given path should be fetched in a single query. The type of join used will be specified by joinType, and defaults to a LEFT JOIN.
Gid [jvm]
@Embeddable
data class Gid<R : DbRoot<R>, T : DbSharded<R, T>>(val rootId: Id<R>, val id: Id<T>) : Serializable
Entity group id, maps to two long columns one for the root id and one for the row
GidGenerator [jvm]
class GidGenerator : AbstractPostInsertGenerator, Configurable
Group [jvm]
annotation class Group(val paths: Array<String> = [])
Annotates a function on a Query interface to indicate that the results should be grouped by the given paths. This is most useful with Projections and aggregations.
HibernateEntityModule [jvm]
abstract class HibernateEntityModule(qualifier: KClass<out Annotation>) : KAbstractModule
Binds hibernate entities and event listeners intended for the Transacter annotated by qualifier.
HibernateExceptionLogLevelConfig [jvm]
data class HibernateExceptionLogLevelConfig@JvmOverloadsconstructor(val log_level: Level = Level.WARN) : Config
Configures the log Level for a HibernateException.
HibernateModule [jvm]
class HibernateModule@JvmOverloadsconstructor(qualifier: KClass<out Annotation>, config: DataSourceConfig, readerQualifier: KClass<out Annotation>?, readerConfig: DataSourceConfig?, val databasePool: DatabasePool = RealDatabasePool, logLevelConfig: HibernateExceptionLogLevelConfig = HibernateExceptionLogLevelConfig()) : KAbstractModule
Id [jvm]
data class Id<T : DbEntity<T>>(val id: Long) : Serializable, Comparable<Id<T>>
Type-safe persistent identifier, mapped to a long column.
IdType [jvm]
class IdType : UserType, ResultSetIdentifierConsumer
Binds Id<*> in the DB to a bigint in MySQL.
JsonColumn [jvm]
@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class JsonColumn
Put this on a column field to get Hibernate to persist it as JSON using Moshi. It will use the injector’s configured Moshi instance. Use misk.moshi.MoshiModule to customize.
Operator [jvm]
enum Operator : Enum<Operator>
OrBuilder [jvm]
interface OrBuilder<Q : Query<*>>
This functional interface accepts a set of options. Each option lambda is executed within the scope of a query. It is inappropriate to call methods like list() and uniqueResult() on this query.
Order [jvm]
annotation class Order(val path: String, val asc: Boolean = true)
Annotates a function on a Query interface to indicate by which columns to order the results. Defaults to ascending order.
Path [jvm]
data class Path(val schema: String?, val table: String?, val column: String?)
PostCommitHookFailedException [jvm]
class PostCommitHookFailedException(cause: Throwable) : Exception
PostCommitHookFailedException is raised when a code run as part of a post-commit hook fails. Because post-commit hooks are run after the transaction is committed, failure in these hooks does not cause the transaction to rollback, and applications may need to differentiate the two cases (exception occurred and caused the transaction to rollback, exception occurred during a post-commit hook
Projection [jvm]
interface Projection
Marker interface for query projections.
Property [jvm]
annotation class Property(val path: String, val aggregation: AggregationType = AggregationType.NONE)
Annotates a parameter of a Projection data class to indicate which column (or path of columns) to populate the parameter with.
ProtoColumn [jvm]
@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class ProtoColumn
Put this on a column field for a class generated by Wire to get Hibernate to persist with protobuf serialization.
Query [jvm]
interface Query<T>
Base class for SQL queries.
RetryTransactionException [jvm]
class RetryTransactionException@JvmOverloadsconstructor(message: String? = null, cause: Throwable? = null) : Exception
Thrown to explicitly trigger a retry, subject to retry limits and config such as noRetries().
SecretColumn [jvm]
@Target(allowedTargets = [AnnotationTarget.FIELD])
annotation class SecretColumn(val keyName: String, val indexable: Boolean = true)
SecretColumn is an annotation used to get Hibernate to encrypt a field before writing it to the database.
Select [jvm]
annotation class Select(val path: String = "", val aggregation: AggregationType = AggregationType.NONE)
Annotates a function on a Query interface to execute a SELECT query. Functions with this annotation must return a List to fetch multiple rows results, or a regular type to fetch a unique result.
Session [jvm]
interface Session : Session
Transacter [jvm]
interface Transacter
Provides explicit block-based transaction demarcation.
TransacterService [jvm]
interface TransacterService : Service
Marker interface for services that provide database transactors.
TransformedType [jvm]
@Target(allowedTargets = [AnnotationTarget.ANNOTATION_CLASS])
annotation class TransformedType(val transformer: KClass<out Transformer>, val targetType: KClass<*>)
TransformedType is a meta-annotation for assigning arbitrary transformers to entity fields. Use it to annotate attributes that will mark a field to be transformed.
Transformer [jvm]
abstract class Transformer(val context: TransformerContext)
TransformerContext [jvm]
data class TransformerContext(val tableName: String, val columnName: String, var arguments: Map<String, >, var field: KClass<>)
ValidationReport [jvm]
data class ValidationReport(val schemas: Set<String>, val tables: Set<String>, val columns: Set<String>)
VitessDialect [jvm]
class VitessDialect : MySQL57Dialect

Functions

Name Summary
allowFullScatter [jvm]
inline fun <T, Q : Query<T>> Q.allowFullScatter(): Q
allowTableScan [jvm]
inline fun <T, Q : Query<T>> Q.allowTableScan(): Q
constraint [jvm]
fun <T, Q : Query<T>> Q.constraint(block: CriteriaBuilder.(root: Root<*>) -> Predicate): Q
Equivalent to Query.addConstraint, but takes the CriteriaBuilder as a receiver and returns this. This may be easier to use with method chaining.
failSafeRead [jvm]
fun <T> Transacter.failSafeRead(block: (session: Session) -> T): T
Runs a read on master first then tries it on replicas on failure. This method is here only for health check purpose for standby regions.
[jvm]
fun <T> Transacter.failSafeRead(shard: Shard, block: (session: Session) -> T): T
getByType [jvm]
fun ResultSet.getByType(klass: KClass<*>?, columnLabel: String): Serializable?
load [jvm]
inline fun <T : DbEntity<T>> Session.load(id: Id<T>): T
loadOrNull [jvm]
inline fun <T : DbEntity<T>> Session.loadOrNull(id: Id<T>): T?
loadSharded [jvm]
inline fun <R : DbRoot<R>, S : DbSharded<R, S>> Session.loadSharded(gid: Gid<R, S>): S
newQuery [jvm]
inline fun <T : Query<*>> Query.Factory.newQuery(): T
or [jvm]
inline fun <T, Q : Query<T>> Q.or(lambda: OrBuilder<Q>.() -> Unit): Q
Collects options that are all OR’d together. If any are true the predicate matches.
queryHint [jvm]
fun <T, Q : Query<T>> Q.queryHint(hint: String): Q
Adds query hint to the query. (Chainable version of Query.addQueryHint.)
setByType [jvm]
fun PreparedStatement.setByType(klass: KClass<*>?, index: Int, value: Any)
shards [jvm]
fun Transacter.shards(): Set<Shard>
fun Transacter.shards(keyspace: Keyspace): Collection<Shard>
transaction [jvm]
fun <T> Transacter.transaction(shard: Shard, block: (session: Session) -> T): T
Commits a transaction with operations of block.