public class OMA extends BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
mapper
used to communicate with JDBC / SQL databases.Modifier and Type | Field and Description |
---|---|
static SQLFilterFactory |
FILTERS
Constains the factory used to generate filters for a
SmartQuery . |
static sirius.kernel.health.Log |
LOG
Contains the central logger for the OMA facility.
|
mixing, VERSION
Constructor and Description |
---|
OMA() |
Modifier and Type | Method and Description |
---|---|
protected void |
createEntity(SQLEntity entity,
EntityDescriptor ed)
Creates a new entity in the underlying database.
|
protected void |
deleteEntity(SQLEntity entity,
boolean force,
EntityDescriptor ed)
Deletes the give entity from the database.
|
protected <E extends SQLEntity> |
execFind(Object id,
EntityDescriptor ed,
Connection c) |
FilterFactory<SQLConstraint> |
filters()
Returns the filter factory which is used by this mapper.
|
protected <E extends SQLEntity> |
findEntity(E entity) |
protected <E extends SQLEntity> |
findEntity(Object id,
EntityDescriptor ed,
Function<String,sirius.kernel.commons.Value> context)
Tries to find the entity with the given id
|
Database |
getDatabase(String realm)
Provides the underlying database instance used to perform the actual statements.
|
sirius.kernel.async.Future |
getReadyFuture()
Provides a
Future which is fullfilled once the framework is ready. |
boolean |
isReady()
Determines if the framework is ready yet.
|
static void |
loadCreatedId(SQLEntity entity,
Row keys)
Loads an auto generated id from the given row.
|
<E extends SQLEntity> |
select(Class<E> type)
Creates a query for the given type.
|
<E extends SQLEntity> |
transform(Class<E> type,
SQLQuery qry)
Transforms a plain
SQLQuery to directly return entities of the given type. |
<E extends SQLEntity> |
transform(Class<E> type,
String alias,
SQLQuery qry)
Same as
transform(Class, SQLQuery) but with support for aliased columns. |
protected void |
updateEntity(SQLEntity entity,
boolean force,
EntityDescriptor ed)
Updates an existing entity in the underlying database.
|
delete, find, findOrFail, forceDelete, hasValidationWarnings, override, performDelete, performUpdate, refreshOrFail, resolve, resolveOrFail, tryDelete, tryRefresh, tryUpdate, update, validate
public static final sirius.kernel.health.Log LOG
public static final SQLFilterFactory FILTERS
SmartQuery
.@Nullable public Database getDatabase(String realm)
realm
- the realm to determine the database forpublic sirius.kernel.async.Future getReadyFuture()
Future
which is fullfilled once the framework is ready.public boolean isReady()
protected void createEntity(SQLEntity entity, EntityDescriptor ed) throws Exception
BaseMapper
createEntity
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
entity
- the entity to createed
- the descriptor of the entityException
- in case of an database errorpublic static void loadCreatedId(SQLEntity entity, Row keys)
entity
- the target entity to write the id tokeys
- the row to read the id fromprotected void updateEntity(SQLEntity entity, boolean force, EntityDescriptor ed) throws Exception
BaseMapper
updateEntity
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
entity
- the entity to updateforce
- ture if the update is forced and optimistic locking must be disableded
- the descriptor of the entityException
- in case of an database errorprotected void deleteEntity(SQLEntity entity, boolean force, EntityDescriptor ed) throws Exception
BaseMapper
deleteEntity
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
entity
- the entity to deleteforce
- true if the delete is forced and optimistic locking must be disableded
- the descriptor of the entityException
- in case of an database errorpublic <E extends SQLEntity> SmartQuery<E> select(Class<E> type)
BaseMapper
select
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
E
- the generic type of entities to be returnedtype
- the type of entities to query for.public FilterFactory<SQLConstraint> filters()
BaseMapper
filters
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
public <E extends SQLEntity> TransformedQuery<E> transform(Class<E> type, SQLQuery qry)
SQLQuery
to directly return entities of the given type.E
- the generic type of entities to read from the query resulttype
- the type of entites to read from the query resultqry
- the query to transformpublic <E extends SQLEntity> TransformedQuery<E> transform(Class<E> type, String alias, SQLQuery qry)
transform(Class, SQLQuery)
but with support for aliased columns.
If the columns to read from the result set are aliased, this method can be used to specify the alias to use.
E
- the generic type of entities to read from the query resulttype
- the type of entites to read from the query resultalias
- the alias which is appended to all column names to readlqry
- the query to transformprotected <E extends SQLEntity> Optional<E> findEntity(Object id, EntityDescriptor ed, Function<String,sirius.kernel.commons.Value> context) throws Exception
findEntity
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
E
- the generic type of the entity tp findid
- the id of the entity to finded
- the descriptor of the entity to findcontext
- the advanced search context which can be populated using
context info elements
.Exception
- in case of a database or system errorprotected <E extends SQLEntity> Optional<E> execFind(Object id, EntityDescriptor ed, Connection c) throws Exception
Exception
protected <E extends SQLEntity> Optional<E> findEntity(E entity)
findEntity
in class BaseMapper<SQLEntity,SQLConstraint,SmartQuery<? extends SQLEntity>>
Copyright © 2018. All rights reserved.