public interface EntityConnection
Entitys and running database
operations specified by a single Domain model.
executeFunction(String, Object...) and executeProcedure(String, Object...)
do not perform any transaction control but insert(List), update(List) and
delete(List) perform a commit unless they are run within a transaction.| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Begins a transaction on this connection
|
void |
commitTransaction()
Performs a commit and ends the current transaction
|
void |
delete(EntityCondition condition)
Deletes the entities specified by the given condition.
|
void |
delete(java.util.List<Entity.Key> entityKeys)
Deletes the entities according to the given primary keys.
|
void |
disconnect()
Performs a rollback and disconnects this connection
|
java.util.List |
executeFunction(java.lang.String functionId,
java.lang.Object... arguments)
Executes the function with the given id
|
void |
executeProcedure(java.lang.String procedureId,
java.lang.Object... arguments)
Executes the procedure with the given id
|
ReportResult |
fillReport(ReportWrapper reportWrapper)
Takes a ReportWrapper object using a JDBC datasource and returns an initialized ReportResult object
|
Domain |
getDomain() |
User |
getUser() |
java.util.List<Entity.Key> |
insert(java.util.List<Entity> entities)
Inserts the given entities, returning a list containing the primary keys of the inserted entities
in the same order as they were received.
|
boolean |
isConnected() |
boolean |
isTransactionOpen() |
byte[] |
readBlob(Entity.Key primaryKey,
java.lang.String blobPropertyId)
Reads the blob specified by the property identified by
propertyId from the given entity |
void |
rollbackTransaction()
Performs a rollback and ends the current transaction
|
java.util.Map<java.lang.String,java.util.Collection<Entity>> |
selectDependencies(java.util.Collection<Entity> entities)
Returns the entities that depend on the given entities via (non-soft) foreign keys, mapped to corresponding entityIds
|
java.util.List<Entity> |
selectMany(EntitySelectCondition condition)
Selects entities according to the specified condition
|
java.util.List<Entity> |
selectMany(java.util.List<Entity.Key> keys)
Returns entities according to
keys |
java.util.List<Entity> |
selectMany(java.lang.String entityId,
java.lang.String propertyId,
java.lang.Object... values)
Selects entities according to one property (
propertyId), using values as a condition |
int |
selectRowCount(EntityCondition condition)
Selects the number of rows returned according to the given condition
|
Entity |
selectSingle(Entity.Key key)
Selects a single entity by key
|
Entity |
selectSingle(EntitySelectCondition condition)
Selects a single entity according to the specified condition, throws a DatabaseException
if the condition results in more than one entity
|
Entity |
selectSingle(java.lang.String entityId,
java.lang.String propertyId,
java.lang.Object value)
Selects a single entity
|
java.util.List<java.lang.Object> |
selectValues(java.lang.String propertyId,
EntityCondition condition)
Selects ordered and distinct non-null values of the given property, note that the given property
must be of type
ColumnProperty. |
java.util.List<Entity> |
update(java.util.List<Entity> entities)
Updates the given entities according to their properties.
|
void |
writeBlob(Entity.Key primaryKey,
java.lang.String blobPropertyId,
byte[] blobData)
Writes
blobData in the blob field specified by the property identified by propertyId
for the given entity |
Domain getDomain()
User getUser()
boolean isConnected()
void disconnect()
boolean isTransactionOpen()
void beginTransaction()
java.lang.IllegalStateException - if a transaction is already openvoid rollbackTransaction()
java.lang.IllegalStateException - in case a transaction is not openvoid commitTransaction()
java.lang.IllegalStateException - in case a transaction is not openjava.util.List executeFunction(java.lang.String functionId,
java.lang.Object... arguments)
throws DatabaseException
functionId - the function IDarguments - the arguments, if anyDatabaseException - in case anything goes wrong during the executionvoid executeProcedure(java.lang.String procedureId,
java.lang.Object... arguments)
throws DatabaseException
procedureId - the procedure IDarguments - the arguments, if anyDatabaseException - in case anything goes wrong during the executionjava.util.List<Entity.Key> insert(java.util.List<Entity> entities) throws DatabaseException
entities - the entities to insertDatabaseException - in case of a database exceptionjava.util.List<Entity> update(java.util.List<Entity> entities) throws DatabaseException
entities - the entities to updateDatabaseException - in case of a database exceptionUpdateException - in case there is a mismatch between expected and actual number of updated rowsRecordModifiedException - in case an entity has been modified or deleted by another uservoid delete(java.util.List<Entity.Key> entityKeys) throws DatabaseException
entityKeys - the primary keys of the entities to deleteDatabaseException - in case of a database exceptionvoid delete(EntityCondition condition) throws DatabaseException
condition - the condition specifying the entities to deleteDatabaseException - in case of a database exceptionjava.util.List<java.lang.Object> selectValues(java.lang.String propertyId,
EntityCondition condition)
throws DatabaseException
ColumnProperty.propertyId - the ID of the propertycondition - the conditionDatabaseException - in case of a database exceptionjava.lang.IllegalArgumentException - in case the given property is not a column based propertyjava.lang.UnsupportedOperationException - in case the entity is based on a select queryEntity selectSingle(java.lang.String entityId, java.lang.String propertyId, java.lang.Object value) throws DatabaseException
entityId - the entity typepropertyId - the ID of the property to use as a conditionvalue - the value to use in the conditionentityId, having the
value of propertyId as valueDatabaseException - in case of a database exceptionRecordNotFoundException - in case the entity was not foundMultipleRecordsFoundException - in case multiple entities were foundEntity selectSingle(Entity.Key key) throws DatabaseException
key - the key of the entity to selectkeyDatabaseException - in case of a database exceptionRecordNotFoundException - in case the entity was not foundMultipleRecordsFoundException - in case multiple entities were foundEntity selectSingle(EntitySelectCondition condition) throws DatabaseException
condition - the condition specifying the entity to selectDatabaseException - in case of a database exceptionRecordNotFoundException - in case the entity was not foundMultipleRecordsFoundException - in case multiple entities were foundjava.util.List<Entity> selectMany(java.util.List<Entity.Key> keys) throws DatabaseException
keyskeys - the keys used in the conditionkeysDatabaseException - in case of a database exceptionjava.util.List<Entity> selectMany(EntitySelectCondition condition) throws DatabaseException
condition - the condition specifying which entities to selectDatabaseException - in case of a database exceptionjava.util.List<Entity> selectMany(java.lang.String entityId, java.lang.String propertyId, java.lang.Object... values) throws DatabaseException
propertyId), using values as a conditionentityId - the entity typepropertyId - the ID of the condition propertyvalues - the property values to use as conditionentityId according to propertyId and valuesDatabaseException - in case of a database exceptionjava.util.Map<java.lang.String,java.util.Collection<Entity>> selectDependencies(java.util.Collection<Entity> entities) throws DatabaseException
entities - the entities for which to retrieve dependencies, must be of same typeentitiesDatabaseException - in case of a database exceptionForeignKeyProperty.isSoftReference()int selectRowCount(EntityCondition condition) throws DatabaseException
condition - the search conditionDatabaseException - in case of a database exceptionReportResult fillReport(ReportWrapper reportWrapper) throws DatabaseException, ReportException
reportWrapper - the wrapper containing the report to fillDatabaseException - in case of a database exceptionReportException - in case of a report exceptionReportWrapper.fillReport(java.sql.Connection)void writeBlob(Entity.Key primaryKey, java.lang.String blobPropertyId, byte[] blobData) throws DatabaseException
blobData in the blob field specified by the property identified by propertyId
for the given entityprimaryKey - the primary key of the entity for which to write the blob fieldblobPropertyId - the ID of the blob propertyblobData - the blob dataDatabaseException - in case of a database exceptionbyte[] readBlob(Entity.Key primaryKey, java.lang.String blobPropertyId) throws DatabaseException
propertyId from the given entityprimaryKey - the primary key of the entityblobPropertyId - the ID of the blob propertyDatabaseException - in case of a database exception