com.ail.core.persistence
Interface Persistence

All Known Implementing Classes:
Core

public interface Persistence

Core persistence implementation interface. This interface describes the methods that the Core must expose in order to support persistence. The methods exposed also describe the contract between this package and the Core - this package provides a Service implementation for each.

Version:
$Revision: 1.4 $

Method Summary
 void closePersistenceSession()
          Close the open session associated with the current thread and commit.
<T extends Type>
T
create(T object)
          Create a persistent copy of an object.
 void delete(Type object)
          Delete one or more objects from persistent storage.
<T extends Type>
T
load(java.lang.Class<T> type, long systemId)
          Load a specific instance of a type by ID.
 void openPersistenceSession()
          Initiate a persistence session.
 java.util.List<?> query(java.lang.String queryName, java.lang.Object... queryArgs)
          Query persistent storage for the collection of objects returned by a query.
 Type queryUnique(java.lang.String queryName, java.lang.Object... queryArgs)
          Query persistent storage for the single object returned by a query.
<T extends Type>
T
update(T object)
          Update the persistent copy of an object from its in memory copy.
 

Method Detail

create

<T extends Type> T create(T object)
Create a persistent copy of an object.

Parameters:
The - object to be persisted.
Returns:
The object as it was persisted

query

java.util.List<?> query(java.lang.String queryName,
                        java.lang.Object... queryArgs)
Query persistent storage for the collection of objects returned by a query. The query itself is referenced by name only. This name is interpreted by the underlying persistence engine and resolved to an actual query.

Parameters:
queryName - The name of the query to be executed.
queryArgs - Arguments to be used by the query.
Returns:
The results of the query.
Throws:
VersionException - The version argument is either badly defined, or relates to a version that does not exist.

queryUnique

Type queryUnique(java.lang.String queryName,
                 java.lang.Object... queryArgs)
Query persistent storage for the single object returned by a query. The query itself is referenced by name only. This name is interpreted by the underlying persistence engine and resolved to an actual query.

Parameters:
queryName - The name of the query to be executed.
queryArgs - Arguments to be used by the query.
Returns:
The results of the query.
Throws:
VersionException - The version argument is either badly defined, or relates to a version that does not exist.

load

<T extends Type> T load(java.lang.Class<T> type,
                        long systemId)
Load a specific instance of a type by ID. This has the same effect as a named query with the following query: from <type> where systemId=<systemId>.

Parameters:
type - The type to be loaded
systemId - the systemId of the instance to load.
Returns:

update

<T extends Type> T update(T object)
Update the persistent copy of an object from its in memory copy.

Parameters:
object - The object to be written to persistent storage.
Returns:
The object as persisted.

delete

void delete(Type object)
Delete one or more objects from persistent storage.

Parameters:
object - Object to be deleted
Throws:
VersionException - If the version object is badly defined, or relates to a version that does not exist.

openPersistenceSession

void openPersistenceSession()
Initiate a persistence session. All persistence related methods need to operate within the context of a session. This call generally corresponds to the start of a transaction. The session is associated with the calling thread, so any persistent methods made within the same thread before closePersistenceSession() are performed within one transaction.


closePersistenceSession

void closePersistenceSession()
Close the open session associated with the current thread and commit.

See Also:
openPersistenceSession()