| java.lang.Object hu.netmind.persistence.Database
Database | public class Database implements TransactionListener(Code) | | This is the frontend class for databases. All common functions are
here regarding database handling, and the specific database calls
are mostly in database implementations. The following tasks are
currently handled by this frontend:
- Transaction handling. Implementations only receive connections
from here on
- Table name handling. All table names are transformed to match
the maximum length supported by database software. Implementations
are guaranteed to receive only good table names.
- Table column name handling. All attribute names are transformed
to suitable column names. Reserved words will be escaped.
- Keeping track of transaction statistics.
author: Brautigam Robert version: Revision: $Revision$ |
Inner Class :public class TranslatorMap implements Map | |
Method Summary | |
public void | ensureTable(Transaction transaction, String tableName, Map attributeTypes, List keyAttributeNames, boolean create) Ensure that table exists in database. | public ConnectionSource | getConnectionSource() Get the connection source of this database. | public void | insert(Transaction transaction, String tableName, Map attributes) Insert an object into the database. | public void | release() Release all resources. | public void | remove(Transaction transaction, String tableName, Map attributes) Remove an entry from database. | public void | save(Transaction transaction, String tableName, Map keys, Map attributes) Modifies an object already in database with given fields. | public SearchResult | search(Transaction transaction, QueryStatement stmt, Limits limits) Select objects from database as ordered list of attribute maps.
Parameters: transaction - The transaction to run in. Parameters: stmt - The query statement. Parameters: limits - The limits of the result. | public void | transactionCommited(Transaction transaction) Activate table names added in the transaction. | public void | transactionRolledback(Transaction transaction) Discard table names added in the transaction. |
ensureTable | public void ensureTable(Transaction transaction, String tableName, Map attributeTypes, List keyAttributeNames, boolean create)(Code) | | Ensure that table exists in database.
Parameters: tableName - The table to check. Parameters: attributeTypes - The attribute names together with whichjava class they should hold. Parameters: create - If true, create table physically, if false, onlyupdate internal representations, but do not create table. |
getConnectionSource | public ConnectionSource getConnectionSource()(Code) | | Get the connection source of this database.
|
insert | public void insert(Transaction transaction, String tableName, Map attributes)(Code) | | Insert an object into the database.
Parameters: tableName - The table to save attributes to. Parameters: id - The id of object to save (All object entries have an id). Parameters: attributes - The attributes in form of name:value pairs. |
release | public void release()(Code) | | Release all resources.
|
remove | public void remove(Transaction transaction, String tableName, Map attributes)(Code) | | Remove an entry from database.
Parameters: tableName - The table to remove object from. Parameters: attributes - The attributes which identify the object.Equality is assumed with each attribute and it's value. |
save | public void save(Transaction transaction, String tableName, Map keys, Map attributes)(Code) | | Modifies an object already in database with given fields.
Parameters: tableName - The table to save attributes to. Parameters: keys - The keys of object to save (All object entries have keys). Parameters: attributes - The attributes in form of name:value pairs. |
search | public SearchResult search(Transaction transaction, QueryStatement stmt, Limits limits)(Code) | | Select objects from database as ordered list of attribute maps.
Parameters: transaction - The transaction to run in. Parameters: stmt - The query statement. Parameters: limits - The limits of the result. (Offset, maximum result count) The result object. |
transactionCommited | public void transactionCommited(Transaction transaction)(Code) | | Activate table names added in the transaction.
|
transactionRolledback | public void transactionRolledback(Transaction transaction)(Code) | | Discard table names added in the transaction.
|
|
|