Package com.rosivanyshyn.db.dao.implMySQL

# 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.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static interface`
  `GenericDAOImpl.DBStatementOperations<T>`
  Substitute Values in DB Queries through statement
  `protected static interface`
  `GenericDAOImpl.ExtractEntity<T>`
  Extract entity from ResultSet in JavaBean
  `protected static interface`
  `GenericDAOImpl.SetGeneratedValuesToEntity<T>`
  Receive getGeneratedKeys from preparedStatement
  and update current entity for which them was generated.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final String`
  `className`
  `protected static final org.apache.log4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GenericDAOImpl()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `countRowsInLastQuery(Connection con)`
  Count the number of rows in the last query
  Last query should have SQL_CALC_FOUND_ROWS part!!!
  `Boolean`
  `delete(Connection con, Long id)`
  Delete object from respective table by id.
  `T`
  `get(Connection con, Long id)`
  Get object from respective table by id.
  `ArrayList<T>`
  `getAll(Connection con)`
  Get all objects from respective table.
  `T`
  `getByField(Connection con, String field, Object value)`
  Find entity from respective table by field and value.
  `ArrayList<T>`
  `getFew(Connection con, int start, int total)`
  Get few objects from respective table.
  `ArrayList<T>`
  `getWithDynamicQuery(Connection con, String secondQueryPart, Object... fields)`
  Get objects from respective table by using query builder string part
  `Boolean`
  `insert(Connection con, T object)`
  Add specific object to respective table.
  `Boolean`
  `update(Connection con, T object)`
  Update object in respective table.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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