All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.univocity.api.entity.jdbc.SqlProducer Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
/*******************************************************************************
 * Copyright (c) 2014 uniVocity Software Pty Ltd. All rights reserved.
 * This file is subject to the terms and conditions defined in file
 * 'LICENSE.txt', which is part of this source code package.
 ******************************************************************************/
package com.univocity.api.entity.jdbc;

/**
 * SqlProducer allows custom generation of SQL statements. Instances of this class are meant to be used in {@link 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: * *

    *
  • Deactivating rows using: "UPDATE table SET active = 'N' WHERE condition" instead of executing the default "DELETE FROM table WHERE condition". *
  • *
  • To prevent deactivated rows being selected into uniVocity, you will then need to produce select statements such as *
    "SELECT * FROM table WHERE active = 'Y' *
  • *
* *

Note: *
The identifiers provided in the methods of this class might have been escaped by {@link 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. * * @see JdbcEntityConfiguration * @see IdentifierEscaper * * @author uniVocity Software Pty Ltd - [email protected] */ public abstract class SqlProducer { /** * Creates a custom select statement. * * @param tableName the name of the database table to be selected * @param columnNames the sequence of column names selected from the table. *

Note: These identifiers might have been escaped. * @return a custom select statement or {@code null} if the default select statement produced by uniVocity should be used. */ public String newSelectStatement(String tableName, String[] columnNames) { return null; } /** * Creates a custom insert statement. * * @param tableName the name of the database table that will receive new records * @param columnNames the sequence of column names that will receive new records *

Note: These identifiers might have been escaped. * @return a custom insert statement or {@code 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) */ public String newInsertStatement(String tableName, String[] columnNames) { return null; } /** * Creates a custom update statement * @param tableName the name of the database table that will have records updated * @param updatedColumns the sequence of column names that will have values modified * @param matchingColumns the sequence of column names that will be used to identify which records should be modified *

Note: These identifiers might have been escaped. * @return a custom update statement or {@code 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 = ? */ public String newUpdateStatement(String tableName, String[] updatedColumns, String[] matchingColumns) { return null; } /** * Creates a custom delete statement * @param tableName the name of the database table that will have records removed * @param matchingColumns the sequence of column names that will be used to identify which records should be deleted *

Note: These identifiers might have been escaped. * @return a custom delete statement or {@code 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 = ? */ public String newDeleteStatement(String tableName, String[] matchingColumns) { return null; } /** * Creates a custom delete statement to delete all records of a table. * @param tableName the name of the database table that will have all records removed *

Note: The tableName might have been escaped. * @return a custom delete statement or {@code null} if the default delete statement produced by uniVocity should be used. */ public String newDeleteAllStatement(String tableName) { return null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy