Class DOFWSql

java.lang.Object
org.eclnt.ccee.db.dofw.DOFWSql
All Implemented Interfaces:
ICCEEConstants

public class DOFWSql extends Object implements ICCEEConstants
  • Constructor Details

    • DOFWSql

      public DOFWSql()
  • Method Details

    • initialize

      public static void initialize(ISQLQueryUpdate sqlQueryUpdate)
    • queryOne

      public static <OBJTYPE> OBJTYPE queryOne(Class<OBJTYPE> clazz, Object... colVals)
      Query that exactly returns one (or none) object. Executes a normal query but only returns the first item of the result set.
    • queryOne

      public static <OBJTYPE> OBJTYPE queryOne(Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
    • queryOne

      public static <OBJTYPE> OBJTYPE queryOne(String contextName, Class<OBJTYPE> clazz, Object... colVals)
    • queryOne

      public static <OBJTYPE> OBJTYPE queryOne(String contextName, Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
    • queryGuidedSql

      public static List<Object[]> queryGuidedSql(Class clazz, String[] colSelections, String conditionString, String orderString, Object[] values)
      Short version of #queryFreeStyle(String, Class, String[], String, String, Object[]) without explicitly passing some context.
    • queryGuidedSql

      public static List<Object[]> queryGuidedSql(String contextName, Class clazz, String[] colSelections, String conditionString, String orderString, Object[] values)
      Free style query in which you can pass free style strings.
      ?p(propertyName) ==> property reference
      ?v() ==> value without reference
      ?v(propertyName) ==> value reference
      Parameters:
      contextName -
      clazz -
      colSelections - Example: "?p(firstName), ?p(lastName), concat(?p(firstName),?p(lastName))"
      conditionString - Example: "?p(firstName) = ?v(firstName) AND concat(?p(firstName),?p(lastName))=?v()"
      May be passed a null.
      orderString - Example: "?p(firstName)"
      May be passed as null.
      Returns:
      Resultset as list - the value classes are adapted according to the property definitions.
    • query

      public static <OBJTYPE> List<OBJTYPE> query(Class<OBJTYPE> clazz, Object... colVals)
      Query data of one class/table.
    • query

      public static <OBJTYPE> List<OBJTYPE> query(String contextName, Class<OBJTYPE> clazz, Object... colVals)
    • queryTop

      public static <OBJTYPE> List<OBJTYPE> queryTop(Class<OBJTYPE> clazz, int top, Object... colVals)
      Query data of one class/table - but only query for a limited number of return objects.
    • queryTop

      public static <OBJTYPE> List<OBJTYPE> queryTop(String contextName, Class<OBJTYPE> clazz, int top, Object... colVals)
    • queryTop

      public static <OBJTYPE> List<OBJTYPE> queryTop(Class<OBJTYPE> clazz, int top, Object[] colVals, Object[] orderBy)
      Query data of one class/table - but only query for a limited number of return objects.
    • queryTop

      public static <OBJTYPE> List<OBJTYPE> queryTop(String contextName, Class<OBJTYPE> clazz, int top, Object[] colVals, Object[] orderBy)
    • queryRange

      public static <OBJTYPE> List<OBJTYPE> queryRange(Class<OBJTYPE> clazz, int rangeOffset, int rangeCount, Object... colVals)
      Query data of one class/table - but only query for a limited number of return objects.
    • queryRange

      public static <OBJTYPE> List<OBJTYPE> queryRange(String contextName, Class<OBJTYPE> clazz, int rangeOffset, int rangeCount, Object... colVals)
    • queryRange

      public static <OBJTYPE> List<OBJTYPE> queryRange(Class<OBJTYPE> clazz, int rangeOffset, int rangeCount, Object[] colVals, Object[] orderBy)
      Query data of one class/table - but only query for a limited number of return objects.
    • queryRange

      public static <OBJTYPE> List<OBJTYPE> queryRange(String contextName, Class<OBJTYPE> clazz, int rangeOffset, int rangeCount, Object[] colVals, Object[] orderBy)
    • query

      public static <OBJTYPE> List<OBJTYPE> query(Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
      Query data of one class/table - now with order by clause.
    • query

      public static <OBJTYPE> List<OBJTYPE> query(String contextName, Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
    • queryColumnData

      public static <OBJTYPE> List<OBJTYPE> queryColumnData(Class<OBJTYPE> clazz, Object[] colSelection, Object... colVals)
      This version of query only request certain columns to be loaded. The objects returned as consequence are only partially filled with data.
    • queryColumnData

      public static <OBJTYPE> List<OBJTYPE> queryColumnData(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, Object... colVals)
      This version of query only request certain columns to be loaded. The objects returned as consequence are only partially filled with data.
    • queryColumnData

      public static <OBJTYPE> List<OBJTYPE> queryColumnData(Class<OBJTYPE> clazz, Object[] colSelection, Object[] colVals, Object[] orderBy)
      This version of query only request certain columns to be loaded. The objects returned as consequence are only partially filled with data.
    • queryColumnData

      public static <OBJTYPE> List<OBJTYPE> queryColumnData(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, Object[] colVals, Object[] orderBy)
      This version of query only request certain columns to be loaded. The objects returned as consequence are only partially filled with data.
    • queryColumnDataDistinct

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataDistinct(Class<OBJTYPE> clazz, Object[] colSelection, Object[] colVals, Object[] orderBy)
      Same as queryColumnData(Class, Object[], Object[], Object[]) but now performing a "SELECT DISTINCT" instead of a plain "SELECT".
    • queryColumnDataDistinct

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataDistinct(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, Object[] colVals, Object[] orderBy)
      Same as queryColumnData(String, Class, Object[], Object[], Object[]) but now performing a "SELECT DISTINCT" instead of a plain "SELECT".
    • queryColumnDataTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataTop(Class<OBJTYPE> clazz, Object[] colSelection, int top, Object... colVals)
      This version of query only request certain properties to be loaded. The objects returned as consequence are only partially filled with data.
      Parameters:
      colSelection - Property names which should be selected.
    • queryColumnDataTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataTop(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, int top, Object... colVals)
      This version of query only request certain properties to be loaded. The objects returned as consequence are only partially filled with data.
      Parameters:
      colSelection - Property names which should be selected.
    • queryColumnDataTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataTop(Class<OBJTYPE> clazz, Object[] colSelection, int top, Object[] colVals, Object[] orderBy)
      This version of query only request certain properties to be loaded. The objects returned as consequence are only partially filled with data.
      Parameters:
      colSelection - Property names which should be selected.
    • queryColumnDataTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataTop(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, int top, Object[] colVals, Object[] orderBy)
      This version of query only request certain properties to be loaded. The objects returned as consequence are only partially filled with data.
      Parameters:
      colSelection - Property names which should be selected.
    • queryColumnDataDistinctTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataDistinctTop(Class<OBJTYPE> clazz, Object[] colSelection, int top, Object[] colVals, Object[] orderBy)
      Same as queryColumnDataTop(Class, Object[], int, Object[], Object[]) but now peforming a "SELECT DISTINCT" instead of a normal "SELECT".
    • queryColumnDataDistinctTop

      public static <OBJTYPE> List<OBJTYPE> queryColumnDataDistinctTop(String contextName, Class<OBJTYPE> clazz, Object[] colSelection, int top, Object[] colVals, Object[] orderBy)
      Same as queryColumnDataTop(String, Class, Object[], int, Object[], Object[]) but now peforming a "SELECT DISTINCT" instead of a normal "SELECT".
    • queryCrossTenant

      public static <OBJTYPE> List<OBJTYPE> queryCrossTenant(Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
      Query data of one class/table without automated sub selection of the tenant.
    • queryCrossTenant

      public static <OBJTYPE> List<OBJTYPE> queryCrossTenant(String contextName, Class<OBJTYPE> clazz, Object[] colVals, Object[] orderBy)
    • updateColumnsByQuery

      public static int updateColumnsByQuery(Class clazz, Object[] queryColVals, Object[] updateColVals)
    • updateColumnsByQuery

      public static int updateColumnsByQuery(String contextName, Class clazz, Object[] queryColVals, Object[] updateColVals)
      Update database items directly.
      Parameters:
      context -
      clazz -
      queryColVals - Query objects - defines which objects to be affected by the update. Just normal object array as used with any query.
      updateColVals - Update values - array containg sequence of pairs of objects: propertyName, value, propertyName, value, ...
      Returns:
      Number of updated items
    • queryDistinct

      public static List<Map<String,Object>> queryDistinct(Class clazz, String[] propertyNames, Object[] colVals)
    • queryDistinct

      public static List<Map<String,Object>> queryDistinct(String contextName, Class clazz, String[] propertyNames, Object[] colVals)
    • queryFunction

      public static Object queryFunction(Class clazz, String functionName, String property, Object[] colVals)
      Executes a SQL function for a specific column/property and for a specific where condition. Only use the functions that are defined in ICCEEConstants as parameter.
    • queryFunction

      public static Object queryFunction(String contextName, Class clazz, String functionName, String functionPropertyName, Object[] colVals)
    • queryFunctionGrouped

      public static List<Object[]> queryFunctionGrouped(Class clazz, String functionName, String functionPropertyName, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Executes SQL function with grouping. See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryFunctionGrouped

      public static List<Object[]> queryFunctionGrouped(Class clazz, int top, String functionName, String functionPropertyName, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Executes SQL function with grouping. See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryFunctionGrouped

      public static List<Object[]> queryFunctionGrouped(String contextName, Class clazz, String functionName, String functionPropertyName, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Executes SQL function with grouping. See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryGrouped

      public static List<Object[]> queryGrouped(Class clazz, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Execute SQL with grouping (SELECT ... GROUP BY ...).
      See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryGrouped

      public static List<Object[]> queryGrouped(String contextName, Class clazz, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Execute SQL with grouping (SELECT ... GROUP BY ...).
      See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryGrouped

      public static List<Object[]> queryGrouped(Class clazz, int top, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Execute SQL with grouping (SELECT ... GROUP BY ...).
      See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryGrouped

      public static List<Object[]> queryGrouped(String contextName, Class clazz, int top, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Execute SQL with grouping (SELECT ... GROUP BY ...).
      See queryFunctionGrouped(String, Class, int, String, String, String[], Object[], Object[]) for explanation on parameters.
    • queryFunctionGrouped

      public static List<Object[]> queryFunctionGrouped(String contextName, Class clazz, int top, String functionName, String functionPropertyName, String[] groupPropertyNames, Object[] colVals, Object[] orderBy)
      Executes SQL function with grouping.
      Parameters:
      top - number of rows to load from database, if defined <= 0 then all rows are loaded.
      functionName - Name of function - use one of the constants defined in ICCEEConstants, e.g. ICCEEConstants.COUNT.
      functionPropertyName - Property name on which function is executed.
      colVals - Query WHERE parameters.
      orderBy - Query ORDER BY parameters.
      Returns:
      Object array for each result line. The first object (index 0) is the value of the function, the subsequent objectts are the values of the groupProperties in the sequence in which they are passed by paramter groupPropertyNames.
    • checkIfObjectAlreadyExists

      public static boolean checkIfObjectAlreadyExists(Object dob)
      Checks if an object with the same key already exists in the database.
    • checkIfObjectAlreadyExists

      public static boolean checkIfObjectAlreadyExists(String contextName, Object dob)
      Checks if an object with the same key already exists in the database.
    • rereadObject

      public static boolean rereadObject(Object dob)
      Reread object from database. The refreshed data is filled into the current instance.
      Returns:
      true => reread was executed, false => reread could not be executed because object is not available anymore
    • rereadObject

      public static boolean rereadObject(String contextName, Object dob)
      See rereadObject(Object) - now with explicitly passing contextName.
    • rereadObject

      public static boolean rereadObject(String contextName, Object dob, DynSqlAddon dynSqlAddon)
    • querySameObject

      public static Object querySameObject(Object dob)
    • querySameObject

      public static Object querySameObject(String contextName, Object dob)
      Re-queries the object that is passed- so that the object is re-read from the database. This method passes back the newly read instance. Use rereadObject(String, Object) if you want to transfer the newly read object into the object instance that is passed.
    • querySameObject

      public static Object querySameObject(String contextName, Object dob, DynSqlAddon dynSqlAddon)
    • deleteObjectsInBatch

      public static void deleteObjectsInBatch(Object[] dobs)
      Deletion of several objects in one batch statement.
      Parameters:
      dobs - All objects must belong to the same class. Inhomogenous arrays are not allowed!
    • deleteObjectsInBatch

      public static void deleteObjectsInBatch(String contextName, Object[] dobs)
      Same as deleteObjectsInBatch(Object[]) but now with addtional contextName.
    • deleteObject

      public static boolean deleteObject(Object dob)
      Deletes object from database.
    • deleteObject

      public static boolean deleteObject(String contextName, Object dob)
      Same as deleteObject(Object), but now with explicit database context passed.
    • delete

      public static int delete(Class clazz, Object... colVals)
    • delete

      public static int delete(String contextName, Class clazz, Object... colVals)
    • truncate

      public static void truncate(Class clazz)
      Removes the content of the whole table. This statement is NOT executed if the table is used by several tenants - separated by some tenant column.
    • truncate

      public static void truncate(String contextName, Class clazz)
      Removes the content of the whole table. This statement is NOT executed if the table is used by several tenants - separated by some tenant column.
    • saveObject

      public static void saveObject(Object dob)
      First tries to update object - if this fails then an insert is done. As consequence the object will be added to the database, regardless if it is a new or if it is an existing object.
    • saveObject

      public static void saveObject(String contextName, Object dob)
      Extended version of saveObject(Object) - with passing the contextName.
    • insertObjectsInBatch

      public static void insertObjectsInBatch(Object[] dobs)
      Insert of several objects in one batch statement.
      Parameters:
      dobs - All objects must belong to the same class. Inhomogenous arrays are not allowed!
    • insertObjectsInBatch

      public static void insertObjectsInBatch(String contextName, Object[] dobs)
      Extended version of insertObjectsInBatch(Object[]) - with passing the contextName.
    • insertObject

      public static boolean insertObject(Object dob)
      Inserts object into database.
      Returns:
      indicator if object was inserted (true) or not inserted (false).
    • insertObject

      public static boolean insertObject(String contextName, Object dob)
      Same as insertObject(Object) but now passing contextName of database.
    • updateObjectsInBatch

      public static void updateObjectsInBatch(Object[] dobs)
    • updateObjectsInBatch

      public static void updateObjectsInBatch(String contextName, Object[] dobs)
      Update of several objects in one batch statement.
      Parameters:
      contextName -
      dobs - All objects must belong to the same class. Inhomogenous arrays are not allowed!
    • updateObject

      public static boolean updateObject(Object dob)
      Updates the object.
    • updateObject

      public static boolean updateObject(String contextName, Object dob)
      Updates the object.
    • mapResultSetList

      public static <OBJTYPE> void mapResultSetList(ResultSet rs, Class<OBJTYPE> dobClass, List<OBJTYPE> dos)
      Same as mapResultSetList(String, ResultSet, Class, List), using the default context.
    • mapResultSetList

      public static <OBJTYPE> void mapResultSetList(ResultSet rs, Class<OBJTYPE> dobClass, Object[] colSelection, List<OBJTYPE> dos)
    • mapResultSetList

      public static <OBJTYPE> void mapResultSetList(String contextName, ResultSet rs, Class<OBJTYPE> dobClass, List<OBJTYPE> dos)
      Map result set into a list of objects.
      Parameters:
      contextName -
      rs -
      dobClass - Type of objects that are created.
      dos - List in which the newly craeted objects are added.
    • mapResultSetList

      public static <OBJTYPE> void mapResultSetList(String contextName, ResultSet rs, Class<OBJTYPE> dobClass, Object[] colSelection, List<OBJTYPE> dos)
    • mapResultSet

      public static <OBJTYPE> OBJTYPE mapResultSet(ResultSet rs, Class<OBJTYPE> dobClass, Object[] colSelection)
      Same as #mapResultSet(String, ResultSet, Class) but using the default context.
    • mapResultSet

      public static <OBJTYPE> OBJTYPE mapResultSet(String contextName, ResultSet rs, Class<OBJTYPE> dobClass, Object[] colSelection)
      Map result set data into object.
      Parameters:
      contextName -
      rs -
      dobClass -
      Returns:
    • mapResultSet

      public static <OBJTYPE> OBJTYPE mapResultSet(String contextName, ResultSet rs, Object[] colSelection, OBJTYPE dob)
    • preparseSql

      public static Object[] preparseSql(Class clazz, DOFWEntity entity, Object[] sql)
      Parses the SQL and replaces certain contstructs so that result sql corresponds to internally processed format.