com.jenkov.mrpersister.itf
Interface IPersistenceConfiguration

All Known Implementing Classes:
PersistenceConfiguration

public interface IPersistenceConfiguration

This interface represents a persistence configuration which is a collection of Mr. Persister compononents used to achieve persistence in a certain way. You can have different persistence configurations suiting different databases or situations etc if helps you. The persistence configuration also makes it easier to pass around all the different components to be used in a specific situation, for instance read-by-primary-key, or inser / updateBatch / delete etc.

Author:
Jakob Jenkov, Jenkov Development

Method Summary
 java.lang.Object getConfigurationKey()
          Returns the key by which this persistence configuration is stored internally in the MrPersister class.
 ICustomObjectMapper getCustomObjectMapper()
          Returns the custom object mapper of this persistence configuration.
 Database getDatabase()
          Returns the Database instance representing the database this instance is specialized for.
 javax.sql.DataSource getDataSource()
          Gets the data source associated with this persistence configuration.
 ISqlCache getDeleteSqlCache()
          Returns the SQL cache used to store delete statements in this persistence configuration.
 ISqlCache getInsertSqlCache()
          Returns the SQL cache used to store insert SQL statements in this persistence configuration.
 IObjectMapper getObjectMapper()
          Returns the object mapper used in this persistence configuration.
 IObjectMappingCache getObjectMappingCache()
          Returns the object mapping cache used in this persistence configuration.
 IObjectReader getObjectReader()
          Returns the object reader used in this persistence configuration.
 IObjectWriter getObjectWriter()
          Returns the object writer used in this persistence configuration.
 ISqlCache getReadByPrimaryKeySqlCache()
          Returns the SQL cache used to store read-by-primary-key SQL statements in this persistence configuration.
 IScopeFactory getScopeFactory()
          Returns the scope factory matching the data source set on this persistence configuration.
 ISqlGenerator getSqlGenerator()
          Returns the SQL generator used with this persistence configuration.
 ISqlCache getUpdateOptimisticSqlCache()
          Returns the SQL cache used to store updateOptimistic SQL statements in this persistence configuration.
 ISqlCache getUpdateSqlCache()
          Returns the SQL cache used to store updateBatch SQL statements in this persistence configuration.
 void setConfigurationKey(java.lang.Object key)
          Sets the key by which this persistence configuration is stored internally in the MrPersister class.
 void setCustomObjectMapper(ICustomObjectMapper customMapper)
          Sets the custom object mapper of this persistence configuration.
 void setDatabase(Database database)
          Sets the database this configuration is specialized for.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the data source associated with this persistence configuration.
 void setDeleteSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store delete SQL statements in this persistence configuration.
 void setInsertSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store insert SQL statements in this persistence configuration.
 void setObjectMapper(IObjectMapper mapper)
          Sets the object mapper to be used with this persistence configuration.
 void setObjectMappingCache(IObjectMappingCache cache)
          Sets the object mapping cache to be used in this persistence configuration.
 void setObjectReader(IObjectReader reader)
          Sets the object reader to be used with this persistence configuration.
 void setObjectWriter(IObjectWriter writer)
          Sets the object writer to use with this persistence configuration.
 void setReadByPrimaryKeySqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store read-by-primary-key SQL statements in this persistence configuration.
 void setSqlGenerator(ISqlGenerator generator)
          Sets the SQL generator to be used with this persistence configuration.
 void setUpdateOptimisticSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store updateOptimistic SQL statements in this persistence configuration.
 void setUpdateSqlCache(ISqlCache cache)
          Sets the SQL cache to be used to store updateBatch SQL statements in this persistence configuration.
 void update()
          Updates the MrPersister class with any changes made to this IPersistenceConfiguration.
 

Method Detail

getDatabase

Database getDatabase()
Returns the Database instance representing the database this instance is specialized for.

Returns:
The Database instance represeting the database this instance is specialized for.

setDatabase

void setDatabase(Database database)
Sets the database this configuration is specialized for. Note that simply setting the database instance isn't enough to target the entire configuration to another database. If you change the database instance you will have to change the other components manually, or you will have a semantically incoherent persistence configuration. In other words: Do not change the database configuration unless you know what you are doing.


getDataSource

javax.sql.DataSource getDataSource()
Gets the data source associated with this persistence configuration.

Returns:
The data source associated with this persistence configuration.

setDataSource

void setDataSource(javax.sql.DataSource dataSource)
Sets the data source associated with this persistence configuration.


getScopeFactory

IScopeFactory getScopeFactory()
Returns the scope factory matching the data source set on this persistence configuration. A scope factory is automatically created when a DataSource is set on an IPersistenceConfiguration.

Returns:
The scope factory matching the data source set on this persistence configuration.

getConfigurationKey

java.lang.Object getConfigurationKey()
Returns the key by which this persistence configuration is stored internally in the MrPersister class.

Returns:
The key by which this persistence configuration is stored internally in the MrPersister class.

setConfigurationKey

void setConfigurationKey(java.lang.Object key)
Sets the key by which this persistence configuration is stored internally in the MrPersister class. Note: Changing the key in the IPersistenceConfiguration instance will not remap the instance stored in the MrPersister class. You will have to remove the previously stored IPersistenceConfiguration yourself.

Calling the updateBatch method of a IPersistenceConfiguration instance will however store that instance by the new key. But the instance will remain mapped to the old key as well in the MrPersister class.

Parameters:
key - key by which this persistence configuration is stored internally in the MrPersister class, until you specifically remove that instance from the MrPersister class.

update

void update()
Updates the MrPersister class with any changes made to this IPersistenceConfiguration. This method must be called whenever changes have been made to any of the objects stored in this persistence configuration. This must be done to assure that changes to a persistence configuration by one thread, are also visible to other threads using it. This does not include objects inserted or removed from the various caches, as these are already prepared to handle concurrency. Only changes to the other components, or if components in this persistence configuraion are replaced by others.


getObjectMapper

IObjectMapper getObjectMapper()
Returns the object mapper used in this persistence configuration.

Returns:
The IObjectMapper instance set in this persistence configuration.

setObjectMapper

void setObjectMapper(IObjectMapper mapper)
Sets the object mapper to be used with this persistence configuration.

Parameters:
mapper - The IObjectMapper instance to use with this persistence configuration.

getObjectMappingCache

IObjectMappingCache getObjectMappingCache()
Returns the object mapping cache used in this persistence configuration.

Returns:
The IObjectMappingCache instance set in this persistence configuration.

setObjectMappingCache

void setObjectMappingCache(IObjectMappingCache cache)
Sets the object mapping cache to be used in this persistence configuration.

Parameters:
cache - The IObjectMappingCache instance to use in this persistence configuration.

getObjectReader

IObjectReader getObjectReader()
Returns the object reader used in this persistence configuration.

Returns:
The IObjectReader instance set in this persistence configuration.

setObjectReader

void setObjectReader(IObjectReader reader)
Sets the object reader to be used with this persistence configuration.

Parameters:
reader - The IObjectReader instance to use with this persistence configuration

getObjectWriter

IObjectWriter getObjectWriter()
Returns the object writer used in this persistence configuration.

Returns:
The IObjectWriter instance set in this persistence configuration.

setObjectWriter

void setObjectWriter(IObjectWriter writer)
Sets the object writer to use with this persistence configuration.

Parameters:
writer - The IObjectWriter instance to use with this persistence configuration.

getSqlGenerator

ISqlGenerator getSqlGenerator()
Returns the SQL generator used with this persistence configuration.

Returns:
The ISqlGenerator instance set in this persistence configuration.

setSqlGenerator

void setSqlGenerator(ISqlGenerator generator)
Sets the SQL generator to be used with this persistence configuration.

Parameters:
generator - The ISqlGenerator instance to be used with this persistence configuration.

getReadByPrimaryKeySqlCache

ISqlCache getReadByPrimaryKeySqlCache()
Returns the SQL cache used to store read-by-primary-key SQL statements in this persistence configuration.

Returns:
The ISqlCache instance used to store read-by-primary-key SQL statements in this persistence configuration.

setReadByPrimaryKeySqlCache

void setReadByPrimaryKeySqlCache(ISqlCache cache)
Sets the SQL cache to be used to store read-by-primary-key SQL statements in this persistence configuration.

Parameters:
cache - The ISqlCache instance to be used to store read-by-primary-key SQL statements in this persistence configuration.

getInsertSqlCache

ISqlCache getInsertSqlCache()
Returns the SQL cache used to store insert SQL statements in this persistence configuration.

Returns:
The ISqlCache instance used to store insert SQL statements in this persistence configuration.

setInsertSqlCache

void setInsertSqlCache(ISqlCache cache)
Sets the SQL cache to be used to store insert SQL statements in this persistence configuration.

Parameters:
cache - The ISqlCache instance to be used to store insert SQL statements in this persistence configuration.

getUpdateSqlCache

ISqlCache getUpdateSqlCache()
Returns the SQL cache used to store updateBatch SQL statements in this persistence configuration.

Returns:
The ISqlCache instance used to store updateBatch SQL statements in this persistence configuration.

setUpdateSqlCache

void setUpdateSqlCache(ISqlCache cache)
Sets the SQL cache to be used to store updateBatch SQL statements in this persistence configuration.

Parameters:
cache - The ISqlCache instance to be used to store updateBatch SQL statements in this persistence configuration.

getUpdateOptimisticSqlCache

ISqlCache getUpdateOptimisticSqlCache()
Returns the SQL cache used to store updateOptimistic SQL statements in this persistence configuration.

Returns:
The ISqlCache instance used to store updateOptimistic SQL statements in this persistence configuration.

setUpdateOptimisticSqlCache

void setUpdateOptimisticSqlCache(ISqlCache cache)
Sets the SQL cache to be used to store updateOptimistic SQL statements in this persistence configuration.

Parameters:
cache - The ISqlCache instance to be used to store updateOptimistic SQL statements in this persistence configuration.

getDeleteSqlCache

ISqlCache getDeleteSqlCache()
Returns the SQL cache used to store delete statements in this persistence configuration.

Returns:
The ISqlCache instance used to store delete SQL statements in this persistence configuration.

setDeleteSqlCache

void setDeleteSqlCache(ISqlCache cache)
Sets the SQL cache to be used to store delete SQL statements in this persistence configuration.

Parameters:
cache - The ISqlCache instance to be used to store delete SQL statements in this persistence configuration.

getCustomObjectMapper

ICustomObjectMapper getCustomObjectMapper()
Returns the custom object mapper of this persistence configuration. Currently unused. May be deprecated in a future release. Set the custom mappers directly on the ObjectMappingKey instances instead.

Returns:
the custom object mapper of this persistence configuration.

setCustomObjectMapper

void setCustomObjectMapper(ICustomObjectMapper customMapper)
Sets the custom object mapper of this persistence configuration. Currently unused. May be deprecated in a future release. Set the custom mappers directly on the ObjectMappingKey instances instead.

Parameters:
customMapper - The custom object mapper to set on this persistence configuration.