|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jenkov.mrpersister.MrPersister
public class MrPersister
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 |
---|
public MrPersister()
Method Detail |
---|
public static IPersistenceConfigurationFactory getConfigurationFactory()
MrPersister.createConfiguration()
methods.
public static void setConfigurationFactory(IPersistenceConfigurationFactory factory)
MrPersister.createConfiguration()
methods.
You should never have to change the persistence factory. Only do so if you know what you
are doing.
factory
- The persistence factory to use.public static IObjectMappingFactory getObjectMappingFactory()
public static void setObjectMappingFactory(IObjectMappingFactory factory)
factory
- The object method factory to be used with the Mr. Persister API.public static IGenericDaoFactory getGenericDaoFactory()
public static void setGenericDaoFactory(IGenericDaoFactory factory)
factory
- The generic dao factory to be used with Mr. Persister.public static IPersistenceConfiguration createConfiguration()
getConfigurationFactory().createConfiguration()
instead.
IPersistenceConfiguration
.
IPersistenceConfiguration
.public static IPersistenceConfiguration getConfiguration(java.lang.Object configurationKey)
configurationKey
- The key to get the persistence configuration for.
IPersistenceConfigurationFactory
public static void setConfiguration(java.lang.Object configurationKey, IPersistenceConfiguration configuration)
configurationKey
- The key to store the persistence configuration by.configuration
- IPersistenceConfigurationFactory
public static void removeConfiguration(java.lang.Object configurationKey)
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.
configurationKey
- The key of the persistence configuration to remove.IPersistenceConfigurationFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |