2.17.2: 2011-06-17

net.sf.basedb.core
Class BatchUtil

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

 class BatchUtil
extends Object

Utility class for batching information.

Version:
2.0
Author:
Samuel, Nicklas
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Field Summary
private static boolean debugEnabled
          So we don't always have to call logSql.debug()
private static boolean isInitialised
           
private static Logger logSql
          Log all SQL statements.
private static Map<String,List<BatchedPropertyInfo>> propertyDeleteOrders
          Mapping classes/entity names to property update orders.
private static Map<String,List<BatchedPropertyInfo>> propertyInsertOrders
          Mapping classes/entity names to property insert orders.
private static Map<String,List<BatchedPropertyInfo>> propertyUpdateOrders
          Mapping classes/entity names to property delete orders.
private static Map<String,String> sqlDeletes
          Mapping classes/entity names to SQL deletes.
private static Map<String,String> sqlInserts
          Mapping classes/entity names to SQL inserts.
private static Map<String,String> sqlUpdates
          Mapping classes/entity names to SQL updates.
 
Constructor Summary
BatchUtil()
           
 
Method Summary
private static void buildDelete(String entityName, org.hibernate.dialect.Dialect dialect)
          Build delete SQL string and put it in the SQL map.
private static void buildInsert(String entityName, org.hibernate.dialect.Dialect dialect)
          Build insert SQL string and put it in the SQL map.
(package private) static String buildInsertSelectSql(VirtualDb vdb, VirtualTable table, VirtualColumn[] columns, String selectSql)
           
(package private) static String buildInsertSql(VirtualDb vdb, VirtualTable table, VirtualColumn[] columns, Object[] values)
           
private static void buildUpdate(String entityName, org.hibernate.dialect.Dialect dialect)
          Build update SQL string and put it in the SQL map.
(package private) static List<BatchedPropertyInfo> getDeletePropertyOrder(Class<? extends BatchableData> dataClass)
          Get the order of properties in the delete SQL.
(package private) static List<BatchedPropertyInfo> getDeletePropertyOrder(String entityName)
          Get the order of properties in the delete SQL.
(package private) static String getDeleteSql(Class<? extends BatchableData> dataClass)
          Get the SQL that deletes a new row of the specified class.
(package private) static String getDeleteSql(String entityName)
          Get the SQL that deletes a new row of the specified class.
(package private) static List<BatchedPropertyInfo> getInsertPropertyOrder(Class<? extends BatchableData> dataClass)
          Get the order of properties in the insert SQL.
(package private) static List<BatchedPropertyInfo> getInsertPropertyOrder(String entityName)
          Get the order of properties in the insert SQL.
(package private) static String getInsertSql(Class<? extends BatchableData> dataClass)
          Get the SQL that inserts a new row of the specified class.
(package private) static String getInsertSql(String entityName)
          Get the SQL that inserts a new row of the specified class.
(package private) static List<BatchedPropertyInfo> getUpdatePropertyOrder(Class<? extends BatchableData> dataClass)
          Get the order of properties in the update SQL.
(package private) static List<BatchedPropertyInfo> getUpdatePropertyOrder(String entityName)
          Get the order of properties in the update SQL.
(package private) static String getUpdateSql(Class<? extends BatchableData> dataClass)
          Get the SQL that updates a new row of the specified class.
(package private) static String getUpdateSql(String entityName)
          Get the SQL that updates a new row of the specified class.
(package private) static void init()
          Generate SQL for all BatchableData classes for insert, update and delete operations.
(package private) static void unload()
          Unload all settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logSql

private static final 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 Detail

BatchUtil

BatchUtil()
Method Detail

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,
                                org.hibernate.dialect.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,
                                org.hibernate.dialect.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,
                                org.hibernate.dialect.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

2.17.2: 2011-06-17