Package com.openmeet.shared.data.storage

# Class GenericDAO

java.lang.Object
com.openmeet.shared.data.storage.GenericDAO

public final class GenericDAO extends Object

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static boolean`
  `genericDoDelete(String table, String condition, DataSource source)`
  Deletes an object in the database.
  `static <E extends ResultSetExtractor<T>, T>
  List<T>`
  `genericDoRetrieveByCondition(String table, String condition, E extractor, DataSource source)`
  Returns a list of objects from the database that match a given condition.
  `static boolean`
  `genericDoSave(String table, HashMap<String,?> map, DataSource source)`
  Saves an object in the database.
  `static boolean`
  `genericDoUpdate(String table, String condition, HashMap<String,?> values, DataSource source)`
  Updates an object in the database.

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

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

- ## Method Details

  - ### genericDoRetrieveByCondition

    public static <E extends ResultSetExtractor<T>, T> List<T> genericDoRetrieveByCondition(String table, String condition, E extractor, DataSource source) throws SQLException
    Returns a list of objects from the database that match a given condition.
    Parameters:
      `table` - the name of the table in the database from which the records are to be retrieved.
      `condition` - the condition that the records should match in order to be retrieved.
      `extractor` - an instance of a class that implements the ResultSetExtractor interface. The extractor is used to convert the ResultSet returned by the database query into a List of objects of the desired type.
      `source` - an instance of DataSource, an object used to establish a connection to the database.
    Returns:
      the query results as a list of objects.
    Throws:
      `SQLException`

  - ### genericDoSave

    public static boolean genericDoSave(String table, HashMap<String,?> map, DataSource source) throws SQLException
    Saves an object in the database.
    Parameters:
      `table` - the name of the table in the database from which the records are to be retrieved.
      `map` - a HashMap representing the data to be saved, where the keys are the column names and the values are the values to be inserted.
      `source` - an instance of DataSource, an object used to establish a connection to the database.
    Returns:
      a boolean value that indicates if the operation was successful or not.
    Throws:
      `SQLException`

  - ### genericDoUpdate

    public static boolean genericDoUpdate(String table, String condition, HashMap<String,?> values, DataSource source) throws SQLException
    Updates an object in the database.
    Parameters:
      `table` - the name of the table in the database from which the records are to be retrieved.
      `condition` - the condition that the records should match in order to be retrieved.
      `values` - a HashMap representing the data to be updated, where the keys are the column names and the values are the new values to be set.
      `source` - an instance of DataSource, an object used to establish a connection to the database.
    Returns:
      a boolean value that indicates if the operation was successful or not.
    Throws:
      `SQLException`

  - ### genericDoDelete

    public static boolean genericDoDelete(String table, String condition, DataSource source) throws SQLException
    Deletes an object in the database.
    Parameters:
      `table` - the name of the table in the database from which the records are to be retrieved.
      `condition` - the condition that the records should match in order to be retrieved.
      `source` - an instance of DataSource, an object used to establish a connection to the database.
    Returns:
      a boolean value that indicates if the operation was successful or not.
    Throws:
      `SQLException`