Package com.softslate.commerce.daos.core
Class BaseDAO
java.lang.Object
com.softslate.commerce.daos.core.BaseDAO
- All Implemented Interfaces:
DAOInterface
- Direct Known Subclasses:
AdministratorDAOHibernate
,AttributeDAOHibernate
,BaseAdminGatewayDAOHibernate
,BasicTaxRateDAOHibernate
,CategoryDAOHibernate
,CategorySettingDAOHibernate
,CountryDAOHibernate
,CustomerAddressDAOHibernate
,CustomerDAOHibernate
,CustomerWishListDAOHibernate
,DiscountDAOHibernate
,DiscountRangeDAOHibernate
,EmailDAOHibernate
,EmailOptOutDAOHibernate
,InstallerDAOBasic
,LiquibaseDAOImpl
,ManufacturerDAOHibernate
,OptionDAOHibernate
,OrderDAOHibernate
,OrderDeliveryDAOHibernate
,OrderDiscountDAOHibernate
,OrderItemAttributeDAOHibernate
,OrderItemDAOHibernate
,OrderSettingDAOHibernate
,OrderShippingRuleDAOHibernate
,PaymentDAOHibernate
,ProductDAOHibernate
,ProductReviewDAOHibernate
,ProductSettingDAOHibernate
,RequestLogDAOHibernate
,RoleDAOHibernate
,ShippingMethodDAOHibernate
,ShippingRateDAOHibernate
,ShippingRuleDAOHibernate
,ShippingRuleRangeDAOHibernate
,SKUDAOHibernate
,StateDAOHibernate
,TemplateDAOHibernate
,UpgradesDAOBasic
Abstract superclass for all objects in the data access layer.
The methods provided allow implementations to communicate with other elements
of the application. In particular, retrieve settings (using
getSettings()
), retrieve database connections (using
getConnection()
), retrieve SQL statements (using
getSqlMap()
and getSQL(java.lang.String, java.lang.String)
), and create other data
access objects (using getDaoFactory()
).
- Author:
- David Tobey
-
Field Summary
Modifier and TypeFieldDescriptionprivate Properties
private Properties
private Connection
private DAOFactory
private DAOUtils
private DataSource
private Map
private com.google.inject.Injector
(package private) static org.apache.commons.logging.Log
private Settings
private Map
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
deleteObject
(Object object, boolean commit) void
doWorkToSetConnection
(org.hibernate.Session session) editAssignment
(BusinessObject item, Map parameters, BusinessObjectFactory bof) void
formatDateTime
(Date dateTime) Formats a Date object into a string suitable for storage in the database.Retrieves this factory's component settings.Retrieves this factory's application settings.Retrieves aConnection
to the application'sDataSource
.Retrieves the application'sDAOFactory
.Retrieves a utility object that provides useful methods for daos.Retrieves the application'sDataSource
.getImportExportSQL
(String module, String key) Returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources/importexport".com.google.inject.Injector
Retrieves theInjector
previously set.org.hibernate.Query
getNamedQuery
(org.hibernate.Session session, String queryName) Returns a custom named query with the "-custom" suffix if one exists, otherwise returns the normally named query.Retrieves theSettings
previously set for this data access object.Legacy method that returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources".Retrieves aMap
of the SQL statements used by the application.void
initialize
(Map transferMap) Initializes this data access object by copying incoming parameters into its properties.insertObject
(Object object, boolean commit) loadAll()
loadAll
(org.hibernate.Filter filter) loadObject
(Object object) parseDateTime
(String dateTime) Formats a Date object into a string suitable for storage in the database.void
setAppComponents
(Properties appComponents) void
setAppSettings
(Properties appSettings) void
setConnection
(Connection connection) void
setDaoFactory
(DAOFactory daoFactory) void
setDAOUtils
(DAOUtils daoUtils) void
setDataSource
(DataSource dataSource) void
setImportExportSqlMap
(Map importExportSqlMap) void
setInjector
(com.google.inject.Injector injector) Sets this object'sInjector
that can be used to create other objects and inject them with dependencies.void
setSettings
(Settings settings) void
updateObject
(Object object, boolean commit)
-
Field Details
-
log
static org.apache.commons.logging.Log log -
settings
-
appSettings
-
appComponents
-
dataSource
-
connection
-
sqlMap
-
importExportSqlMap
-
daoFactory
-
injector
private com.google.inject.Injector injector -
daoUtils
-
-
Constructor Details
-
BaseDAO
public BaseDAO()
-
-
Method Details
-
getSettings
Description copied from interface:DAOInterface
Retrieves theSettings
previously set for this data access object.- Specified by:
getSettings
in interfaceDAOInterface
- Returns:
- A
Settings
object that represents various settings for the system.
-
setSettings
- Specified by:
setSettings
in interfaceDAOInterface
-
getAppSettings
Description copied from interface:DAOInterface
Retrieves this factory's application settings. The current application settings for the system. This factory will pass the application settings to every DAO it creates. The application settings are settings for information unique to a given installation, such as the location of files on the server, as opposed to theSettingsBean
, which stores settings drawn from the database.- Specified by:
getAppSettings
in interfaceDAOInterface
-
setAppSettings
- Specified by:
setAppSettings
in interfaceDAOInterface
-
getAppComponents
Description copied from interface:DAOInterface
Retrieves this factory's component settings. The component settings identify which Java class implement the various Interfaces used by the system.- Specified by:
getAppComponents
in interfaceDAOInterface
-
setAppComponents
- Specified by:
setAppComponents
in interfaceDAOInterface
-
getDataSource
Description copied from interface:DAOInterface
Retrieves the application'sDataSource
.- Specified by:
getDataSource
in interfaceDAOInterface
- Returns:
- The application's
DataSource
.
-
setDataSource
- Specified by:
setDataSource
in interfaceDAOInterface
-
getConnection
Description copied from interface:DAOInterface
Retrieves aConnection
to the application'sDataSource
.- Specified by:
getConnection
in interfaceDAOInterface
- Returns:
- A
Connection
to the application'sDataSource
.
-
setConnection
- Specified by:
setConnection
in interfaceDAOInterface
-
getSqlMap
Description copied from interface:DAOInterface
Retrieves aMap
of the SQL statements used by the application.- Specified by:
getSqlMap
in interfaceDAOInterface
- Returns:
- A
Map
of the SQL statements used by the application.
-
setSqlMap
- Specified by:
setSqlMap
in interfaceDAOInterface
-
getImportExportSqlMap
-
setImportExportSqlMap
-
getDaoFactory
Description copied from interface:DAOInterface
Retrieves the application'sDAOFactory
.- Specified by:
getDaoFactory
in interfaceDAOInterface
- Returns:
- The application's
DAOFactory
.
-
setDaoFactory
- Specified by:
setDaoFactory
in interfaceDAOInterface
-
getInjector
public com.google.inject.Injector getInjector()Description copied from interface:DAOInterface
Retrieves theInjector
previously set.- Specified by:
getInjector
in interfaceDAOInterface
- Returns:
- A
Injector
object that can be used to create other objects and inject them with dependencies.
-
setInjector
@Inject public void setInjector(com.google.inject.Injector injector) Description copied from interface:DAOInterface
Sets this object'sInjector
that can be used to create other objects and inject them with dependencies.- Specified by:
setInjector
in interfaceDAOInterface
- Parameters:
injector
- The currentInjector
for the system, which can be used to create other objects and inject them with dependencies.
-
initialize
Description copied from interface:DAOInterface
Initializes this data access object by copying incoming parameters into its properties. This method is used byDAOFactory
after object creation to copy the application'sDAOFactory
andSettings
into the new object. ThesqlMap
anddataSource
properties are also copied from theDAOFactory
.- Specified by:
initialize
in interfaceDAOInterface
- Parameters:
transferMap
- AMap
containing objects such as the application'sDAOFactory
andSettings
.- Throws:
Exception
-
getSQL
Legacy method that returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources".- Parameters:
module
- The application module corresponding to the desired SQL statement, such as "core", "product", "order", or "customer".key
- A string key for the SQL statement corresponding to the keys in the .properties files.- Returns:
- An SQL statement, or
null
if the requested statement could not be found. - Throws:
Exception
-
getImportExportSQL
Returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources/importexport".- Parameters:
module
- The application module corresponding to the desired SQL statement. Must be "importexport".key
- A string key for the SQL statement corresponding to the keys in the .properties files.- Returns:
- An SQL statement, or
null
if the requested statement could not be found. - Throws:
Exception
-
formatDateTime
Formats a Date object into a string suitable for storage in the database.- Specified by:
formatDateTime
in interfaceDAOInterface
- Parameters:
dateTime
-- Returns:
- a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
-
parseDateTime
Formats a Date object into a string suitable for storage in the database.- Specified by:
parseDateTime
in interfaceDAOInterface
- Parameters:
dateTime
-- Returns:
- a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
- Throws:
Exception
-
getDAOUtils
Description copied from interface:DAOInterface
Retrieves a utility object that provides useful methods for daos.- Specified by:
getDAOUtils
in interfaceDAOInterface
- Returns:
- An implementation of DAOUtils.
-
setDAOUtils
- Specified by:
setDAOUtils
in interfaceDAOInterface
-
getNamedQuery
public org.hibernate.Query getNamedQuery(org.hibernate.Session session, String queryName) throws org.hibernate.HibernateException Returns a custom named query with the "-custom" suffix if one exists, otherwise returns the normally named query.Named queries can be overridden by creating a new query in one of the
queries-custom.hbm.xml
files. The new query must have the same name as the query it's replacing, but with "-custom" appended to the name. This method looks to see if a custom query exists before returning the regular query.- Parameters:
session
- The current Hibernate session.queryName
- The name of the query to return (without the "-custom" suffix).- Returns:
- A Query object.
- Throws:
org.hibernate.HibernateException
-
evictCache
public void evictCache() -
loadObject
- Specified by:
loadObject
in interfaceDAOInterface
- Throws:
Exception
-
updateObject
- Specified by:
updateObject
in interfaceDAOInterface
- Throws:
Exception
-
deleteObject
- Specified by:
deleteObject
in interfaceDAOInterface
- Throws:
Exception
-
insertObject
- Specified by:
insertObject
in interfaceDAOInterface
- Throws:
Exception
-
loadAll
- Specified by:
loadAll
in interfaceDAOInterface
- Throws:
Exception
-
loadAll
- Specified by:
loadAll
in interfaceDAOInterface
- Throws:
Exception
-
doWorkToSetConnection
public void doWorkToSetConnection(org.hibernate.Session session) -
editAssignment
public Map editAssignment(BusinessObject item, Map parameters, BusinessObjectFactory bof) throws Exception - Throws:
Exception
-