Class GenericDAOImpl<T>

java.lang.Object
com.rosivanyshyn.db.dao.implMySQL.GenericDAOImpl<T>
Type Parameters:
T - Entity
All Implemented Interfaces:
GenericDAO<T>
Direct Known Subclasses:
AccountDAOImpl, ApartmentDAOImpl, BookingDAOImpl, OrderDAOImpl, ResponseToOrderDAOImpl

public abstract class GenericDAOImpl<T> extends Object implements GenericDAO<T>
Generic DAO interface implementation.
  • Field Details

    • LOG

      protected static final org.apache.log4j.Logger LOG
    • className

      protected final String className
  • Constructor Details

    • GenericDAOImpl

      public GenericDAOImpl()
  • Method Details

    • insert

      public Boolean insert(Connection con, T object)
      Description copied from interface: GenericDAO
      Add specific object to respective table.
      Specified by:
      insert in interface GenericDAO<T>
      Parameters:
      con - connection to database
      object - object
      Returns:
      Boolean operation result
    • get

      public T get(Connection con, Long id)
      Description copied from interface: GenericDAO
      Get object from respective table by id.
      Specified by:
      get in interface GenericDAO<T>
      Parameters:
      con - connection to database
      id - object id
      Returns:
      T object result field
    • getAll

      public ArrayList<T> getAll(Connection con)
      Description copied from interface: GenericDAO
      Get all objects from respective table.
      Specified by:
      getAll in interface GenericDAO<T>
      Parameters:
      con - connection to database
      Returns:
      ArrayList result array
    • getFew

      public ArrayList<T> getFew(Connection con, int start, int total)
      Description copied from interface: GenericDAO
      Get few objects from respective table.
      Example - start 15, total 50, return records from 15 to 65 (Not from 15 to 50!!!)
      Specified by:
      getFew in interface GenericDAO<T>
      Parameters:
      con - connection to database
      start - which record to start sampling from
      total - records count to get
      Returns:
      ArrayList result array
    • getByField

      public T getByField(Connection con, String field, Object value)
      Description copied from interface: GenericDAO
      Find entity from respective table by field and value.
      Specified by:
      getByField in interface GenericDAO<T>
      Parameters:
      con - connection to database
      field - user field. Doesn`t support foreign keys!!!
      value - user value
      Returns:
      T field
    • getWithDynamicQuery

      public ArrayList<T> getWithDynamicQuery(Connection con, String secondQueryPart, Object... fields)
      Description copied from interface: GenericDAO
      Get objects from respective table by using query builder string part
      Specified by:
      getWithDynamicQuery in interface GenericDAO<T>
      Parameters:
      con - connection to database
      secondQueryPart - query builder string part
      fields - fields for insertion in query builder string part statement
      Returns:
      ArrayList result array
    • update

      public Boolean update(Connection con, T object)
      Description copied from interface: GenericDAO
      Update object in respective table.
      Specified by:
      update in interface GenericDAO<T>
      Parameters:
      con - connection to database
      object - object to update
      Returns:
      Boolean operation result
    • delete

      public Boolean delete(Connection con, Long id)
      Description copied from interface: GenericDAO
      Delete object from respective table by id.
      Specified by:
      delete in interface GenericDAO<T>
      Parameters:
      con - connection to database
      id - object id
      Returns:
      Boolean operation result
    • countRowsInLastQuery

      public int countRowsInLastQuery(Connection con)
      Description copied from interface: GenericDAO
      Count the number of rows in the last query
      Last query should have SQL_CALC_FOUND_ROWS part!!!
      Specified by:
      countRowsInLastQuery in interface GenericDAO<T>
      Parameters:
      con - connection to database
      Returns:
      number of rows