com.univocity.api.entity.jdbc
Class SqlProducer

java.lang.Object
  extended by com.univocity.api.entity.jdbc.SqlProducer

public abstract class SqlProducer
extends Object

SqlProducer allows custom generation of SQL statements. Instances of this class are meant to be used in JdbcEntityConfiguration.setSqlProducer(SqlProducer) to control how the SQL statements of a JDBC data entity are generated.

This is useful to support specific situations such as supporting logical exclusion, for example:

Note:
The identifiers provided in the methods of this class might have been escaped by IdentifierEscaper, i.e. names of columns and tables passed in as parameters can be enclosed within quotes.

You are not required to override all methods of this class. If nulls are returned then the default SQL statements generated by uniVocity will be used.

Author:
uniVocity Software Pty Ltd - dev@univocity.com
See Also:
JdbcEntityConfiguration, IdentifierEscaper

Constructor Summary
SqlProducer()
           
 
Method Summary
 String newDeleteAllStatement(String tableName)
          Creates a custom delete statement to delete all records of a table.
 String newDeleteStatement(String tableName, String[] matchingColumns)
          Creates a custom delete statement
 String newInsertStatement(String tableName, String[] columnNames)
          Creates a custom insert statement.
 String newSelectStatement(String tableName, String[] columnNames)
          Creates a custom select statement.
 String newUpdateStatement(String tableName, String[] updatedColumns, String[] matchingColumns)
          Creates a custom update statement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlProducer

public SqlProducer()
Method Detail

newSelectStatement

public String newSelectStatement(String tableName,
                                 String[] columnNames)
Creates a custom select statement.

Parameters:
tableName - the name of the database table to be selected
columnNames - the sequence of column names selected from the table.

Note: These identifiers might have been escaped.

Returns:
a custom select statement or null if the default select statement produced by uniVocity should be used.

newInsertStatement

public String newInsertStatement(String tableName,
                                 String[] columnNames)
Creates a custom insert statement.

Parameters:
tableName - the name of the database table that will receive new records
columnNames - the sequence of column names that will receive new records

Note: These identifiers might have been escaped.

Returns:
a custom insert statement or null if the default insert statement produced by uniVocity should be used.

Note: The statement must contain wildcards for the values of each column, in their original order. Example:
INSERT INTO tableName (columnNames_1, columnNames_2, my_custom_date) VALUES (?, ?, SYSDATE)


newUpdateStatement

public String newUpdateStatement(String tableName,
                                 String[] updatedColumns,
                                 String[] matchingColumns)
Creates a custom update statement

Parameters:
tableName - the name of the database table that will have records updated
updatedColumns - the sequence of column names that will have values modified
matchingColumns - the sequence of column names that will be used to identify which records should be modified

Note: These identifiers might have been escaped.

Returns:
a custom update statement or null if the default update statement produced by uniVocity should be used.

Note: The statement must contain wildcards for the values of each column, in their original order. Example:
UPDATE tableName SET updatedColumns_1 = ?, updatedColumns_2 = ? WHERE matchingColumns_1 = ? AND my_custom_flag='Y' AND matchingColumns_2 = ?


newDeleteStatement

public String newDeleteStatement(String tableName,
                                 String[] matchingColumns)
Creates a custom delete statement

Parameters:
tableName - the name of the database table that will have records removed
matchingColumns - the sequence of column names that will be used to identify which records should be deleted

Note: These identifiers might have been escaped.

Returns:
a custom delete statement or null if the default delete statement produced by uniVocity should be used.

Note: The statement must contain wildcards for the values of each column, in their original order. Example:
DELETE FROM tableName WHERE my_custom_flag='Y' AND matchingColumns_1 = ? AND matchingColumns_2 = ?


newDeleteAllStatement

public String newDeleteAllStatement(String tableName)
Creates a custom delete statement to delete all records of a table.

Parameters:
tableName - the name of the database table that will have all records removed

Note: The tableName might have been escaped.

Returns:
a custom delete statement or null if the default delete statement produced by uniVocity should be used.


Copyright © 2015 uniVocity Software Pty Ltd. All rights reserved.