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
FieldsModifier and TypeFieldDescriptionprivate Propertiesprivate Propertiesprivate Connectionprivate DAOFactoryprivate DAOUtilsprivate DataSourceprivate Mapprivate com.google.inject.Injector(package private) static org.apache.commons.logging.Logprivate Settingsprivate Map -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleandeleteObject(Object object, boolean commit) voiddoWorkToSetConnection(org.hibernate.Session session) editAssignment(BusinessObject item, Map parameters, BusinessObjectFactory bof) voidformatDateTime(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 aConnectionto 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.InjectorRetrieves theInjectorpreviously set.org.hibernate.QuerygetNamedQuery(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 theSettingspreviously set for this data access object.Legacy method that returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources".Retrieves aMapof the SQL statements used by the application.voidinitialize(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.voidsetAppComponents(Properties appComponents) voidsetAppSettings(Properties appSettings) voidsetConnection(Connection connection) voidsetDaoFactory(DAOFactory daoFactory) voidsetDAOUtils(DAOUtils daoUtils) voidsetDataSource(DataSource dataSource) voidsetImportExportSqlMap(Map importExportSqlMap) voidsetInjector(com.google.inject.Injector injector) Sets this object'sInjectorthat can be used to create other objects and inject them with dependencies.voidsetSettings(Settings settings) voidupdateObject(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:DAOInterfaceRetrieves theSettingspreviously set for this data access object.- Specified by:
getSettingsin interfaceDAOInterface- Returns:
- A
Settingsobject that represents various settings for the system.
-
setSettings
- Specified by:
setSettingsin interfaceDAOInterface
-
getAppSettings
Description copied from interface:DAOInterfaceRetrieves 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:
getAppSettingsin interfaceDAOInterface
-
setAppSettings
- Specified by:
setAppSettingsin interfaceDAOInterface
-
getAppComponents
Description copied from interface:DAOInterfaceRetrieves this factory's component settings. The component settings identify which Java class implement the various Interfaces used by the system.- Specified by:
getAppComponentsin interfaceDAOInterface
-
setAppComponents
- Specified by:
setAppComponentsin interfaceDAOInterface
-
getDataSource
Description copied from interface:DAOInterfaceRetrieves the application'sDataSource.- Specified by:
getDataSourcein interfaceDAOInterface- Returns:
- The application's
DataSource.
-
setDataSource
- Specified by:
setDataSourcein interfaceDAOInterface
-
getConnection
Description copied from interface:DAOInterfaceRetrieves aConnectionto the application'sDataSource.- Specified by:
getConnectionin interfaceDAOInterface- Returns:
- A
Connectionto the application'sDataSource.
-
setConnection
- Specified by:
setConnectionin interfaceDAOInterface
-
getSqlMap
Description copied from interface:DAOInterfaceRetrieves aMapof the SQL statements used by the application.- Specified by:
getSqlMapin interfaceDAOInterface- Returns:
- A
Mapof the SQL statements used by the application.
-
setSqlMap
- Specified by:
setSqlMapin interfaceDAOInterface
-
getImportExportSqlMap
-
setImportExportSqlMap
-
getDaoFactory
Description copied from interface:DAOInterfaceRetrieves the application'sDAOFactory.- Specified by:
getDaoFactoryin interfaceDAOInterface- Returns:
- The application's
DAOFactory.
-
setDaoFactory
- Specified by:
setDaoFactoryin interfaceDAOInterface
-
getInjector
public com.google.inject.Injector getInjector()Description copied from interface:DAOInterfaceRetrieves theInjectorpreviously set.- Specified by:
getInjectorin interfaceDAOInterface- Returns:
- A
Injectorobject 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:DAOInterfaceSets this object'sInjectorthat can be used to create other objects and inject them with dependencies.- Specified by:
setInjectorin interfaceDAOInterface- Parameters:
injector- The currentInjectorfor the system, which can be used to create other objects and inject them with dependencies.
-
initialize
Description copied from interface:DAOInterfaceInitializes this data access object by copying incoming parameters into its properties. This method is used byDAOFactoryafter object creation to copy the application'sDAOFactoryandSettingsinto the new object. ThesqlMapanddataSourceproperties are also copied from theDAOFactory.- Specified by:
initializein interfaceDAOInterface- Parameters:
transferMap- AMapcontaining objects such as the application'sDAOFactoryandSettings.- 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
nullif 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
nullif 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:
formatDateTimein 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:
parseDateTimein 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:DAOInterfaceRetrieves a utility object that provides useful methods for daos.- Specified by:
getDAOUtilsin interfaceDAOInterface- Returns:
- An implementation of DAOUtils.
-
setDAOUtils
- Specified by:
setDAOUtilsin 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.xmlfiles. 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:
loadObjectin interfaceDAOInterface- Throws:
Exception
-
updateObject
- Specified by:
updateObjectin interfaceDAOInterface- Throws:
Exception
-
deleteObject
- Specified by:
deleteObjectin interfaceDAOInterface- Throws:
Exception
-
insertObject
- Specified by:
insertObjectin interfaceDAOInterface- Throws:
Exception
-
loadAll
- Specified by:
loadAllin interfaceDAOInterface- Throws:
Exception
-
loadAll
- Specified by:
loadAllin 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
-