com.elasticpath.persistence
Interface PersistenceEngine

All Known Implementing Classes:
HibernatePersistenceEngineImpl

public interface PersistenceEngine

The perisistence engine interface.


Method Summary
 int bulkUpdate(java.lang.String query)
          Update/delete all objects according to the given query.
 int bulkUpdate(java.lang.String query, java.lang.Object[] parameters)
          Update/delete all objects according to the given query.
 void clear()
          Clear the cache.
 void delete(Persistence object)
          Delete the given persistent instance.
 java.util.List find(java.lang.Class objClass, java.util.List propertyCriteria)
          Retrieve a list of persistent instances of the specified class with the specified property criteria.
 java.util.List find(java.lang.Class objClass, PropertyCriterion propertyCriterion)
          Retrieve a list of persistent instances of the specified class with the specified property criterion.
 java.util.List find(java.lang.Class objClass, RelationCriterion relationCriterion)
          Retrieve a list of persistent instances of the specified class with the specified relation criterion.
 void flush()
          Flush the cache.
 Persistence get(java.lang.Class persistenceClass, long uidPk)
          Get a persistent instance with the given id.
 PersistenceSession getPersistenceSession()
          Returns a session.
 void initialize(java.lang.Object object)
          Initialize the given object.
 Persistence load(java.lang.Class persistenceClass, long uidPk)
          Load a persistent instance with the given id.
 void merge(Persistence object)
          Merge the given persistent instance.
 java.util.List retrieve(java.util.List queries)
          Retrieve a list of persistent instances with the given list of queries.
 java.util.List retrieve(java.util.List queries, java.lang.Object[] parameters)
          Retrieve a list of persistent instances with the given list of queries.
 java.util.List retrieve(java.lang.String query)
          Retrieve a list of persistent instances with the specified query.
 java.util.List retrieve(java.lang.String query, int firstResult, int maxRestuls)
          Retrieve a list of persistent instances with the specified query and bounds, namely, the maximum number of rows to retrieve and / or the first row to retrieve.
 java.util.List retrieve(java.lang.String query, java.lang.Object[] parameters)
          Retrieve a list of persistent instances with the specified query.
 java.util.List retrieve(java.lang.String query, java.lang.Object[] parameters, boolean cacheQuery)
          Retrieve a list of persistent instances with the specified query.
 java.util.List retrieve(java.lang.String queryStr, java.lang.Object[] parameters, int firstResult, int maxRestuls)
          Retrieve a list of persistent instances with the specified query and bounds, namely, the maximum number of rows to retrieve and / or the first row to retrieve.
 void save(Persistence object)
          Persist the given instance.
 void saveOrMerge(Persistence object)
          Save the persistence instance if it's new or merge the persistent instance if it exists.
 void saveOrUpdate(Persistence object)
          Save the persistence instance if it's new or update the persistent instance if it exists.
 void update(Persistence object)
          Update the given persistent instance.
 

Method Detail

bulkUpdate

int bulkUpdate(java.lang.String query)
               throws EpPersistenceException
Update/delete all objects according to the given query.

Parameters:
query - the HQL query
Returns:
the number of instances updated/deleted
Throws:
EpPersistenceException - - in case of persistence errors

bulkUpdate

int bulkUpdate(java.lang.String query,
               java.lang.Object[] parameters)
               throws EpPersistenceException
Update/delete all objects according to the given query.

Parameters:
query - the HQL query
parameters - the prameters to be used with the criteria
Returns:
the number of instances updated/deleted
Throws:
EpPersistenceException - - in case of persistence errors

clear

void clear()
Clear the cache.


delete

void delete(Persistence object)
            throws EpPersistenceException
Delete the given persistent instance.

Parameters:
object - The instance to delete
Throws:
EpPersistenceException - - in case of persistence errors

find

java.util.List find(java.lang.Class objClass,
                    java.util.List propertyCriteria)
                    throws EpPersistenceException
Retrieve a list of persistent instances of the specified class with the specified property criteria.

Parameters:
objClass - Class of the object
propertyCriteria - property criteria for retrieving
Returns:
list of persistence instatnce
Throws:
EpPersistenceException - - in case of persistence errors

find

java.util.List find(java.lang.Class objClass,
                    PropertyCriterion propertyCriterion)
                    throws EpPersistenceException
Retrieve a list of persistent instances of the specified class with the specified property criterion.

Parameters:
objClass - Class of the object
propertyCriterion - property criterion for retrieving
Returns:
list of persistence instatnce
Throws:
EpPersistenceException - - in case of persistence errors

find

java.util.List find(java.lang.Class objClass,
                    RelationCriterion relationCriterion)
                    throws EpPersistenceException
Retrieve a list of persistent instances of the specified class with the specified relation criterion.

Parameters:
objClass - Class of the object
relationCriterion - relation criterion for retrieving
Returns:
list of persistence instatnce
Throws:
EpPersistenceException - - in case of persistence errors

flush

void flush()
Flush the cache.


get

Persistence get(java.lang.Class persistenceClass,
                long uidPk)
                throws EpPersistenceException
Get a persistent instance with the given id. Return null if no matching record exists.

Parameters:
persistenceClass - the persistent class of the given id.
uidPk - the persistent instance id.
Returns:
the persistent instance
Throws:
EpPersistenceException - - in case of persistence errors

getPersistenceSession

PersistenceSession getPersistenceSession()
Returns a session.

Returns:
a session

initialize

void initialize(java.lang.Object object)
Initialize the given object.

Parameters:
object - the object to initialize.

load

Persistence load(java.lang.Class persistenceClass,
                 long uidPk)
                 throws EpPersistenceException
Load a persistent instance with the given id. Throw an unrecoverable exception if there is no matching database row.

Parameters:
persistenceClass - the persistent class of the given id.
uidPk - the persistent instance id.
Returns:
the persistent instance
Throws:
EpPersistenceException - - in case of persistence errors

merge

void merge(Persistence object)
           throws EpPersistenceException
Merge the given persistent instance.

Parameters:
object - the instance to merge
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.util.List queries)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the given list of queries.

Note: all queries must return the same type of data. Their results will be merged into the list returned by this method.

Parameters:
queries - the list of queries
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.util.List queries,
                        java.lang.Object[] parameters)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the given list of queries.

Note: all queries must return the same type of data. Their results will be merged into the list returned by this method.

Parameters:
queries - the list of queries
parameters - the prameters to be used with the given query
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.lang.String query)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the specified query.

Parameters:
query - the query
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.lang.String query,
                        int firstResult,
                        int maxRestuls)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the specified query and bounds, namely, the maximum number of rows to retrieve and / or the first row to retrieve. This help to support pagination.

Parameters:
query - the query
firstResult - the first row to retrieve.
maxRestuls - the maximum number of rows to retrieve.
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.lang.String query,
                        java.lang.Object[] parameters)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the specified query.

Parameters:
query - the query
parameters - the prameters to be used with the given query
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.lang.String query,
                        java.lang.Object[] parameters,
                        boolean cacheQuery)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the specified query.

Parameters:
query - the query
parameters - the prameters to be used with the given query
cacheQuery - set it to true to cache the query result
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

retrieve

java.util.List retrieve(java.lang.String queryStr,
                        java.lang.Object[] parameters,
                        int firstResult,
                        int maxRestuls)
                        throws EpPersistenceException
Retrieve a list of persistent instances with the specified query and bounds, namely, the maximum number of rows to retrieve and / or the first row to retrieve. This help to support pagination.

Parameters:
queryStr - the HQL query string to be executed.
firstResult - the first row to retrieve.
maxRestuls - the maximum number of rows to retrieve.
parameters - the prameters to be used with the criteria
Returns:
a list of persistent instances.
Throws:
EpPersistenceException - - in case of persistence errors

save

void save(Persistence object)
          throws EpPersistenceException
Persist the given instance.

Parameters:
object - the instance to save.
Throws:
EpPersistenceException - - in case of persistence errors

saveOrMerge

void saveOrMerge(Persistence object)
                 throws EpPersistenceException
Save the persistence instance if it's new or merge the persistent instance if it exists.

Parameters:
object - the instance to save or merge
Throws:
EpPersistenceException - - in case of persistence errors

saveOrUpdate

void saveOrUpdate(Persistence object)
                  throws EpPersistenceException
Save the persistence instance if it's new or update the persistent instance if it exists.

Parameters:
object - the instance to save or update
Throws:
EpPersistenceException - - in case of persistence errors

update

void update(Persistence object)
            throws EpPersistenceException
Update the given persistent instance.

Parameters:
object - the instance to update
Throws:
EpPersistenceException - - in case of persistence errors