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

public abstract class BaseDAO extends Object implements DAOInterface
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 Details

    • log

      static org.apache.commons.logging.Log log
    • settings

      private Settings settings
    • appSettings

      private Properties appSettings
    • appComponents

      private Properties appComponents
    • dataSource

      private DataSource dataSource
    • connection

      private Connection connection
    • sqlMap

      private Map sqlMap
    • importExportSqlMap

      private Map importExportSqlMap
    • daoFactory

      private DAOFactory daoFactory
    • injector

      private com.google.inject.Injector injector
    • daoUtils

      private DAOUtils daoUtils
  • Constructor Details

    • BaseDAO

      public BaseDAO()
  • Method Details

    • getSettings

      public Settings getSettings()
      Description copied from interface: DAOInterface
      Retrieves the Settings previously set for this data access object.
      Specified by:
      getSettings in interface DAOInterface
      Returns:
      A Settings object that represents various settings for the system.
    • setSettings

      @Inject public void setSettings(Settings settings)
      Specified by:
      setSettings in interface DAOInterface
    • getAppSettings

      public Properties 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 the SettingsBean, which stores settings drawn from the database.
      Specified by:
      getAppSettings in interface DAOInterface
    • setAppSettings

      @Inject public void setAppSettings(@Named("appSettings") Properties appSettings)
      Specified by:
      setAppSettings in interface DAOInterface
    • getAppComponents

      public Properties 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 interface DAOInterface
    • setAppComponents

      @Inject public void setAppComponents(@Named("appComponents") Properties appComponents)
      Specified by:
      setAppComponents in interface DAOInterface
    • getDataSource

      public DataSource getDataSource()
      Description copied from interface: DAOInterface
      Retrieves the application's DataSource.
      Specified by:
      getDataSource in interface DAOInterface
      Returns:
      The application's DataSource.
    • setDataSource

      public void setDataSource(DataSource dataSource)
      Specified by:
      setDataSource in interface DAOInterface
    • getConnection

      public Connection getConnection()
      Description copied from interface: DAOInterface
      Retrieves a Connection to the application's DataSource.
      Specified by:
      getConnection in interface DAOInterface
      Returns:
      A Connection to the application's DataSource.
    • setConnection

      public void setConnection(Connection connection)
      Specified by:
      setConnection in interface DAOInterface
    • getSqlMap

      public Map getSqlMap()
      Description copied from interface: DAOInterface
      Retrieves a Map of the SQL statements used by the application.
      Specified by:
      getSqlMap in interface DAOInterface
      Returns:
      A Map of the SQL statements used by the application.
    • setSqlMap

      public void setSqlMap(Map sqlMap)
      Specified by:
      setSqlMap in interface DAOInterface
    • getImportExportSqlMap

      public Map getImportExportSqlMap()
    • setImportExportSqlMap

      public void setImportExportSqlMap(Map importExportSqlMap)
    • getDaoFactory

      public DAOFactory getDaoFactory()
      Description copied from interface: DAOInterface
      Retrieves the application's DAOFactory.
      Specified by:
      getDaoFactory in interface DAOInterface
      Returns:
      The application's DAOFactory.
    • setDaoFactory

      @Inject public void setDaoFactory(DAOFactory daoFactory)
      Specified by:
      setDaoFactory in interface DAOInterface
    • getInjector

      public com.google.inject.Injector getInjector()
      Description copied from interface: DAOInterface
      Retrieves the Injector previously set.
      Specified by:
      getInjector in interface DAOInterface
      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's Injector that can be used to create other objects and inject them with dependencies.
      Specified by:
      setInjector in interface DAOInterface
      Parameters:
      injector - The current Injector for the system, which can be used to create other objects and inject them with dependencies.
    • initialize

      public void initialize(Map transferMap) throws Exception
      Description copied from interface: DAOInterface
      Initializes this data access object by copying incoming parameters into its properties. This method is used by DAOFactory after object creation to copy the application's DAOFactory and Settings into the new object. The sqlMap and dataSource properties are also copied from the DAOFactory.
      Specified by:
      initialize in interface DAOInterface
      Parameters:
      transferMap - A Map containing objects such as the application's DAOFactory and Settings.
      Throws:
      Exception
    • getSQL

      public String getSQL(String module, String key) throws Exception
      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

      public String getImportExportSQL(String module, String key) throws Exception
      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

      public String formatDateTime(Date dateTime)
      Formats a Date object into a string suitable for storage in the database.
      Specified by:
      formatDateTime in interface DAOInterface
      Parameters:
      dateTime -
      Returns:
      a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
    • parseDateTime

      public Date parseDateTime(String dateTime) throws Exception
      Formats a Date object into a string suitable for storage in the database.
      Specified by:
      parseDateTime in interface DAOInterface
      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

      public DAOUtils getDAOUtils()
      Description copied from interface: DAOInterface
      Retrieves a utility object that provides useful methods for daos.
      Specified by:
      getDAOUtils in interface DAOInterface
      Returns:
      An implementation of DAOUtils.
    • setDAOUtils

      public void setDAOUtils(DAOUtils daoUtils)
      Specified by:
      setDAOUtils in interface DAOInterface
    • 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

      public Object loadObject(Object object) throws Exception
      Specified by:
      loadObject in interface DAOInterface
      Throws:
      Exception
    • updateObject

      public Object updateObject(Object object, boolean commit) throws Exception
      Specified by:
      updateObject in interface DAOInterface
      Throws:
      Exception
    • deleteObject

      public boolean deleteObject(Object object, boolean commit) throws Exception
      Specified by:
      deleteObject in interface DAOInterface
      Throws:
      Exception
    • insertObject

      public Object insertObject(Object object, boolean commit) throws Exception
      Specified by:
      insertObject in interface DAOInterface
      Throws:
      Exception
    • loadAll

      public Collection loadAll() throws Exception
      Specified by:
      loadAll in interface DAOInterface
      Throws:
      Exception
    • loadAll

      public Collection loadAll(org.hibernate.Filter filter) throws Exception
      Specified by:
      loadAll in interface DAOInterface
      Throws:
      Exception
    • doWorkToSetConnection

      public void doWorkToSetConnection(org.hibernate.Session session)
    • editAssignment

      public Map editAssignment(BusinessObject item, Map parameters, BusinessObjectFactory bof) throws Exception
      Throws:
      Exception