com.jenkov.mrpersister
Class MrPersister

java.lang.Object
  extended by com.jenkov.mrpersister.MrPersister

Deprecated. Use a PersistenceManager instance to obtain the factories instead. Note: PersistenceManager instances should be reused throughout the application lifetime.

public class MrPersister
extends java.lang.Object

This class is the starting point of any Mr Persister action. It is here you access the factories needed to use Mr. Persister. It should not be necessary to change any of the factories, even though it is possible to do so.

The factory you will be using the most is the generic dao factory available using the getGenericDaoFactory() method. The IGenericDao instances created by this factory is the preferred way of using Mr. Persister.

Another way of accessing the Mr. Persister functions is to create a DAO class that extends com.jenkov.mrpersister.impl.AbstractDao. This was the preferred way of using Mr. Persister before v. 2.2.0. The AbstractDao subclass will then have a lot of read / write methods available to it.

Generic DAO example:


IGenericDao dao = MrPersister.getGenericDaoFactory().createDao(connection);

Employee myEmployeeObject = (Employee) dao.readByPrimaryKey(Employee.class, new Integer(employeeId));

dao.insert(myEmployeeObject);
dao.update(myEmployeeObject);
dao.delete(myEmployeeObject);
dao.closeConnection();



This is all there is to it. No mapping files necessary, and no magic classes to extend (anymore). Mr. Persister is capable of guessing most trivial object-to-database mappings itself. If you are wondering how, you should read the user guide / getting started manual for more information.

There are of course a lot more methods available on the IGenericDao instance than the ones shown here.


Constructor Summary
MrPersister()
          Deprecated.  
 
Method Summary
static IPersistenceConfiguration createConfiguration()
          Deprecated. Use getConfigurationFactory().createConfiguration() instead.
static IPersistenceConfiguration getConfiguration(java.lang.Object configurationKey)
          Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory. Use getConfigurationFactory().get()/store() instead.
static IPersistenceConfigurationFactory getConfigurationFactory()
          Deprecated. Returns the persistence configuration factory currently in use.
static IGenericDaoFactory getGenericDaoFactory()
          Deprecated. Returns the generic dao factory currently used by Mr Persister.
static IObjectMappingFactory getObjectMappingFactory()
          Deprecated. Returns the object method factory set for the Mr Persister API.
static void removeConfiguration(java.lang.Object configurationKey)
          Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory.
static void setConfiguration(java.lang.Object configurationKey, IPersistenceConfiguration configuration)
          Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory.
static void setConfigurationFactory(IPersistenceConfigurationFactory factory)
          Deprecated. Sets the persistence configuration factory to be used with Mr.
static void setGenericDaoFactory(IGenericDaoFactory factory)
          Deprecated. Sets the generic dao factory to be used with Mr Persister.
static void setObjectMappingFactory(IObjectMappingFactory factory)
          Deprecated. Sets the object method factory set for the Mr Persister API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MrPersister

public MrPersister()
Deprecated. 
Method Detail

getConfigurationFactory

public static IPersistenceConfigurationFactory getConfigurationFactory()
Deprecated. 
Returns the persistence configuration factory currently in use. The persistence factory replaces the MrPersister.createConfiguration() methods.

Returns:
The persistence factory currently in use.

setConfigurationFactory

public static void setConfigurationFactory(IPersistenceConfigurationFactory factory)
Deprecated. 
Sets the persistence configuration factory to be used with Mr. Persister in the future. The persistence factory replaces the MrPersister.createConfiguration() methods. You should never have to change the persistence factory. Only do so if you know what you are doing.

Parameters:
factory - The persistence factory to use.

getObjectMappingFactory

public static IObjectMappingFactory getObjectMappingFactory()
Deprecated. 
Returns the object method factory set for the Mr Persister API. This is by default set the implementation that comes with Mr. Persister.

Returns:
The object method factory set for the Mr. Persister API.

setObjectMappingFactory

public static void setObjectMappingFactory(IObjectMappingFactory factory)
Deprecated. 
Sets the object method factory set for the Mr Persister API. This is by default set the implementation that comes with Mr. Persister.

Parameters:
factory - The object method factory to be used with the Mr. Persister API.

getGenericDaoFactory

public static IGenericDaoFactory getGenericDaoFactory()
Deprecated. 
Returns the generic dao factory currently used by Mr Persister.

Returns:
The generic dao factory currently used by Mr Persister.

setGenericDaoFactory

public static void setGenericDaoFactory(IGenericDaoFactory factory)
Deprecated. 
Sets the generic dao factory to be used with Mr Persister. Most likely you will not need to change it.

Parameters:
factory - The generic dao factory to be used with Mr. Persister.

createConfiguration

public static IPersistenceConfiguration createConfiguration()
Deprecated. Use getConfigurationFactory().createConfiguration() instead.

Creates a new IPersistenceConfiguration.

Returns:
A new IPersistenceConfiguration.

getConfiguration

public static IPersistenceConfiguration getConfiguration(java.lang.Object configurationKey)
Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory. Use getConfigurationFactory().get()/store() instead.

Returns the persistence configuration stored by the given key. If none is stored by that key an empty persistence configuration is created and stored by that key and then returned. You could use the .class object of an AbstractDao subclass for the key, or any other key you may desire.

Parameters:
configurationKey - The key to get the persistence configuration for.
Returns:
The persistence configuration matching the given key.
See Also:
IPersistenceConfigurationFactory

setConfiguration

public static void setConfiguration(java.lang.Object configurationKey,
                                    IPersistenceConfiguration configuration)
Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory.

Stores the given persistence configuration by the given key. You could use the .class object of an AbstractDao subclass for the key, or any other key you may desire.

Parameters:
configurationKey - The key to store the persistence configuration by.
configuration -
See Also:
IPersistenceConfigurationFactory

removeConfiguration

public static void removeConfiguration(java.lang.Object configurationKey)
Deprecated. The responsiblity of caching persistence configurations has been moved to the persistence configuration factory.

Removes the IPersistenceConfiguration stored for the given configuration key. Note that if you call the getConfigurationOrFail(Object configurationKey) after removing a specific persistence configuration, a blank persistence configuration will be created and returned. A null will not be returned.

Parameters:
configurationKey - The key of the persistence configuration to remove.
See Also:
IPersistenceConfigurationFactory