Package net.sf.basedb.core
Class BatchUtil
java.lang.Object
net.sf.basedb.core.BatchUtil
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 Summary
Modifier and TypeFieldDescriptionprivate static final boolean
So we don't always have to call logSql.debug()private static boolean
private static final Logger
Log all SQL statements.private static Map<String,
List<BatchedPropertyInfo>> Mapping classes/entity names to property update orders.private static Map<String,
List<BatchedPropertyInfo>> Mapping classes/entity names to property insert orders.private static Map<String,
List<BatchedPropertyInfo>> Mapping classes/entity names to property delete orders.Mapping classes/entity names to SQL deletes.Mapping classes/entity names to SQL inserts.Mapping classes/entity names to SQL updates. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
buildDelete
(String entityName, Dialect dialect) Build delete SQL string and put it in the SQL map.private static void
buildInsert
(String entityName, 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, 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.
-
Field Details
-
logSql
Log all SQL statements. -
debugEnabled
private static final boolean debugEnabledSo we don't always have to call logSql.debug() -
propertyInsertOrders
Mapping classes/entity names to property insert orders. -
propertyUpdateOrders
Mapping classes/entity names to property delete orders. -
propertyDeleteOrders
Mapping classes/entity names to property update orders. -
sqlInserts
Mapping classes/entity names to SQL inserts. -
sqlUpdates
Mapping classes/entity names to SQL updates. -
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
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
Get the SQL that inserts a new row of the specified class.- Parameters:
entityName
- The entity name- Returns:
- The SQL string
-
getUpdateSql
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
Get the SQL that updates a new row of the specified class.- Parameters:
entityName
- The entity name- Returns:
- The SQL string
-
getDeleteSql
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
Get the SQL that deletes a new row of the specified class.- Parameters:
entityName
- The entity name- Returns:
- The SQL string
-
getInsertPropertyOrder
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
Get the order of properties in the insert SQL.- Parameters:
entityName
- The entity name- Returns:
- List with the properties in order
-
getUpdatePropertyOrder
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
Get the order of properties in the update SQL.- Parameters:
entityName
- The entity name- Returns:
- List with the properties in order.
-
getDeletePropertyOrder
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
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
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 bedialect
- The database dialect in use
-
buildUpdate
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 bedialect
- The database dialect in use
-
buildDelete
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 bedialect
- The database dialect in use
-