|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.persistence.domainmapper.BaseDomainMapper
Abstract super class for all domain mappers. Provides common create, find, update and delete functionality based on the template methods defined.
Subclasses should implement public find methods that use the base find methods,
but return specific subclasses of BaseDomain
.
Nested Class Summary | |
class |
BaseDomainMapper.BaseDomainResultSetVisitor
Database result set visitor used to retrieve a list of domain objects. |
Field Summary | |
protected static String |
ID
The constant representing the database field name for a primary identifier. |
protected static String |
VERSION
The constant representing the database field name for a version, which is used for concurrency. |
Constructor Summary | |
BaseDomainMapper()
Default constructor |
Method Summary | |
protected abstract void |
addFields(BaseDomain aDomainObject,
UpdatableQuery updatableQuery)
Add field names and values to the given query, which will be used when inserting or updating the given domain object. |
List |
baseFind(BaseDomain parent,
String foreignKeyFieldName)
Find a collection of domain objects for the given parent object. |
List |
baseFind(Condition where)
Creates a select statement using the given condition and then executes the statement to return a list of domain objects. |
protected BaseDomain |
baseFind(Condition where,
String orderByFieldName,
boolean ascending)
Finds a domain object ... |
List |
baseFind(Select select)
Executes the select statement and returns a list of domain objects built from the result set. |
protected BaseDomain |
baseFind(Serializable anId)
Read the domain object of the given Id. |
protected abstract BaseDomain |
build(Serializable id,
long version,
ResultSet resultSet)
Build a domain object from the result set. |
BaseDomain |
create(BaseDomain aDomainObject)
Map the domain to a new record. |
void |
delete(BaseDomain aDomainObject)
Delete the domain objects contents from the database. |
void |
delete(Condition where)
Delete domain objects from the database that match the given condition. |
void |
executeTransaction(AtomicOperationCommand aCommand)
Use this method to bound multiple database operations which need to execute as one atomic operation. |
boolean |
exists(BaseDomain aDomainObject)
Returns whether or not the given domain object exists in the database. |
List |
findAll()
Returns a list containing all domain objects mapped by the receiver. |
List |
findAll(String orderByFieldName,
boolean ascending)
Returns a list containing all domain objects mapped by the receiver, and sorted according to the given field name. |
protected Serializable |
getId(BaseDomain aDomainObject)
Return the given domain object's ID, or null if the domain object is null. |
protected abstract String |
getTableName()
Returns the table name that subclassed mappers represent. |
void |
markTransactionForRollback()
Marks the open transaction for rollback. |
BaseDomain |
save(BaseDomain aDomainObject)
Test for database existence of the given domain object. |
BaseDomain |
update(BaseDomain aDomainObject)
Update the domain objects contents in the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final String ID
protected static final String VERSION
Constructor Detail |
public BaseDomainMapper()
Method Detail |
protected abstract String getTableName()
protected abstract BaseDomain build(Serializable id, long version, ResultSet resultSet) throws DataAccessException, SQLException
id
- The primary identifier for the domain object.version
- The concurrency version for the domain object.resultSet
- The rest of the data to use to build the domain object.
DataAccessException
SQLException
protected abstract void addFields(BaseDomain aDomainObject, UpdatableQuery updatableQuery)
aDomainObject
- The domain object to save.updatableQuery
- The query object that is collecting the domain object fields for saving.protected Serializable getId(BaseDomain aDomainObject)
aDomainObject
- The domain object whose ID is needed.
public BaseDomain create(BaseDomain aDomainObject) throws DataAccessException
aDomainObject
- The domain object to save.
DataAccessException
public List baseFind(Select select) throws DataAccessException
select
- The select statement to use to find the domain objects.
DataAccessException
public List baseFind(Condition where) throws DataAccessException
where
- A where clause condition.
DataAccessException
baseFind(org.arch4j.dataaccess.common.Select)
protected BaseDomain baseFind(Serializable anId) throws DataAccessException
anId
- The primary key identifier for the domain object to find.
DataAccessException
public List baseFind(BaseDomain parent, String foreignKeyFieldName) throws DataAccessException
parent
- The parent domain object.foreignKeyFieldName
- The name of the field that stores the parent's foreign key.
DataAccessException
protected BaseDomain baseFind(Condition where, String orderByFieldName, boolean ascending) throws DataAccessException
where
- orderByFieldName
- ascending
-
DataAccessException
public List findAll() throws DataAccessException
DataAccessException
baseFind(org.arch4j.dataaccess.common.Select)
public List findAll(String orderByFieldName, boolean ascending) throws DataAccessException
orderByFieldName
- The field by which to sort.ascending
- true
, if the sort should be ascending.
DataAccessException
public BaseDomain update(BaseDomain aDomainObject) throws DataAccessException, ConcurrencyException
DataAccessException
ConcurrencyException
public void delete(BaseDomain aDomainObject) throws DataAccessException, ConcurrencyException
DataAccessException
ConcurrencyException
public void delete(Condition where) throws DataAccessException, ConcurrencyException
where
- A where clause condition.
DataAccessException
ConcurrencyException
public BaseDomain save(BaseDomain aDomainObject) throws DataAccessException
aDomainObject
- The domain object to save.
DataAccessException
public boolean exists(BaseDomain aDomainObject)
aDomainObject
- The domain object in question.
true
if the domain object exists in the database.public void executeTransaction(AtomicOperationCommand aCommand) throws DataAccessException
executeTransaction(
new AtomicOperationCommand() {
public void execute() throws DataAccessException {
// do multiple database operations
...
}
}
);
DataAccessException
public void markTransactionForRollback()
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |