Package com.rosivanyshyn.db.dao

# Interface GenericDAO<T>

Type Parameters:
  `T` - – the type of entities

All Known Subinterfaces:
  `AccountDAO`, `ApartmentDAO`, `BookingDAO`, `OrderDAO`, `ResponseToOrderDAO`

All Known Implementing Classes:
  `AccountDAOImpl`, `ApartmentDAOImpl`, `BookingDAOImpl`, `GenericDAOImpl`, `OrderDAOImpl`, `ResponseToOrderDAOImpl`

public interface GenericDAO<T>
Generic DAO interface. Implement methods which are generic for all others DAO

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

- ## Method Details

  - ### insert

    Boolean insert(Connection con, T object)
    Add specific object to respective table.
    Parameters:
      `con` - connection to database
      `object` - object
    Returns:
      Boolean operation result

  - ### get

    T get(Connection con, Long id)
    Get object from respective table by id.
    Parameters:
      `con` - connection to database
      `id` - object id
    Returns:
      T object result field

  - ### getAll

    ArrayList<T> getAll(Connection con)
    Get all objects from respective table.
    Parameters:
      `con` - connection to database
    Returns:
      ArrayList result array

  - ### getFew

    ArrayList<T> getFew(Connection con, int start, int total)
    Get few objects from respective table.
    Example - start 15, total 50, return records from 15 to 65 (Not from 15 to 50!!!)
    Parameters:
      `con` - connection to database
      `start` - which record to start sampling from
      `total` - records count to get
    Returns:
      ArrayList result array

  - ### getByField

    T getByField(Connection con, String field, Object value)
    Find entity from respective table by field and value.
    Parameters:
      `con` - connection to database
      `field` - user field. Doesn`t support foreign keys!!!
      `value` - user value
    Returns:
      T field

  - ### getWithDynamicQuery

    ArrayList<T> getWithDynamicQuery(Connection con, String secondQueryPart, Object... fields)
    Get objects from respective table by using query builder string part
    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

    Boolean update(Connection con, T object)
    Update object in respective table.
    Parameters:
      `con` - connection to database
      `object` - object to update
    Returns:
      Boolean operation result

  - ### delete

    Boolean delete(Connection con, Long id)
    Delete object from respective table by id.
    Parameters:
      `con` - connection to database
      `id` - object id
    Returns:
      Boolean operation result

  - ### countRowsInLastQuery

    int countRowsInLastQuery(Connection con)
    Count the number of rows in the last query
    Last query should have SQL_CALC_FOUND_ROWS part!!!
    Parameters:
      `con` - connection to database
    Returns:
      number of rows