Class BatchUtil

java.lang.Object
net.sf.basedb.core.BatchUtil

class BatchUtil extends Object
Utility class for batching information.
Version:
2.0
Author:
Samuel, Nicklas
Last modified
$Date: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
  • Field Details

    • logSql

      private static final org.slf4j.Logger logSql
      Log all SQL statements.
    • debugEnabled

      private static final boolean debugEnabled
      So we don't always have to call logSql.debug()
    • propertyInsertOrders

      private static Map<String,List<BatchedPropertyInfo>> propertyInsertOrders
      Mapping classes/entity names to property insert orders.
    • propertyUpdateOrders

      private static Map<String,List<BatchedPropertyInfo>> propertyUpdateOrders
      Mapping classes/entity names to property delete orders.
    • propertyDeleteOrders

      private static Map<String,List<BatchedPropertyInfo>> propertyDeleteOrders
      Mapping classes/entity names to property update orders.
    • sqlInserts

      private static Map<String,String> sqlInserts
      Mapping classes/entity names to SQL inserts.
    • sqlUpdates

      private static Map<String,String> sqlUpdates
      Mapping classes/entity names to SQL updates.
    • sqlDeletes

      private static Map<String,String> sqlDeletes
      Mapping classes/entity names to SQL deletes.
    • isInitialised

      private static boolean isInitialised
  • Constructor Details

    • BatchUtil

      BatchUtil()
  • Method Details

    • init

      static void init()
      Generate SQL for all BatchableData classes for insert, update and delete operations. Keep track of the order of parameters and properties in the generated SQL.
    • unload

      static void unload()
      Unload all settings.
    • getInsertSql

      static String getInsertSql(Class<? extends BatchableData> dataClass)
      Get the SQL that inserts a new row of the specified class.
      Parameters:
      dataClass - Get the insert SQL for this class
      Returns:
      The SQL string
    • getInsertSql

      static String getInsertSql(String entityName)
      Get the SQL that inserts a new row of the specified class.
      Parameters:
      entityName - The entity name
      Returns:
      The SQL string
    • getUpdateSql

      static String getUpdateSql(Class<? extends BatchableData> dataClass)
      Get the SQL that updates a new row of the specified class.
      Parameters:
      dataClass - Get the update SQL for this class
      Returns:
      The SQL string
    • getUpdateSql

      static String getUpdateSql(String entityName)
      Get the SQL that updates a new row of the specified class.
      Parameters:
      entityName - The entity name
      Returns:
      The SQL string
    • getDeleteSql

      static String getDeleteSql(Class<? extends BatchableData> dataClass)
      Get the SQL that deletes a new row of the specified class.
      Parameters:
      dataClass - Get the delete SQL for this class
      Returns:
      The SQL string
    • getDeleteSql

      static String getDeleteSql(String entityName)
      Get the SQL that deletes a new row of the specified class.
      Parameters:
      entityName - The entity name
      Returns:
      The SQL string
    • getInsertPropertyOrder

      static List<BatchedPropertyInfo> getInsertPropertyOrder(Class<? extends BatchableData> dataClass)
      Get the order of properties in the insert SQL.
      Parameters:
      dataClass - Get the property order for this class
      Returns:
      List with the properties in order
    • getInsertPropertyOrder

      static List<BatchedPropertyInfo> getInsertPropertyOrder(String entityName)
      Get the order of properties in the insert SQL.
      Parameters:
      entityName - The entity name
      Returns:
      List with the properties in order
    • getUpdatePropertyOrder

      static List<BatchedPropertyInfo> getUpdatePropertyOrder(Class<? extends BatchableData> dataClass)
      Get the order of properties in the update SQL.
      Parameters:
      dataClass - Get the property order for this class.
      Returns:
      List with the properties in order.
    • getUpdatePropertyOrder

      static List<BatchedPropertyInfo> getUpdatePropertyOrder(String entityName)
      Get the order of properties in the update SQL.
      Parameters:
      entityName - The entity name
      Returns:
      List with the properties in order.
    • getDeletePropertyOrder

      static List<BatchedPropertyInfo> getDeletePropertyOrder(Class<? extends BatchableData> dataClass)
      Get the order of properties in the delete SQL.
      Parameters:
      dataClass - Get the property order for this class.
      Returns:
      List with the properties in order.
    • getDeletePropertyOrder

      static List<BatchedPropertyInfo> getDeletePropertyOrder(String entityName)
      Get the order of properties in the delete SQL.
      Parameters:
      entityName - The entity name
      Returns:
      List with the properties in order.
    • buildInsertSql

      static String buildInsertSql(VirtualDb vdb, VirtualTable table, VirtualColumn[] columns, Object[] values)
    • buildInsertSelectSql

      static String buildInsertSelectSql(VirtualDb vdb, VirtualTable table, VirtualColumn[] columns, String selectSql)
    • buildInsert

      private static void buildInsert(String entityName, Dialect dialect)
      Build insert SQL string and put it in the SQL map. Also sets the property order for the class in the order map.
      Parameters:
      entityName - The name of the class to generate the SQL for, the name is usually the same as the class name, but doesn't have to be
      dialect - The database dialect in use
    • buildUpdate

      private static void buildUpdate(String entityName, Dialect dialect)
      Build update SQL string and put it in the SQL map. Also sets the property order for the class in the order map.
      Parameters:
      entityName - The name of the class to generate the SQL for, the name is usually the same as the class name, but doesn't have to be
      dialect - The database dialect in use
    • buildDelete

      private static void buildDelete(String entityName, Dialect dialect)
      Build delete SQL string and put it in the SQL map. Also sets the property order for the class in the order map.
      Parameters:
      entityName - The name of the class to generate the SQL for, the name is usually the same as the class name, but doesn't have to be
      dialect - The database dialect in use