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

org.fluentjdbc.DatabaseStatementFactory Maven / Gradle / Ivy

There is a newer version: 0.5.3
Show newest version
package org.fluentjdbc;

import java.sql.PreparedStatement;
import java.util.List;

/**
 * Controls the creation of {@link DatabaseStatement} objects, which allows for fine custom interception
 * that affects all database operations.
 *
 * 

Currently not used for the bulk operations {@link DatabaseBulkDeleteBuilder}, * {@link DatabaseBulkUpdatable}, {@link DatabaseBulkInsertBuilder} and {@link DbContext} variations of these

*/ public class DatabaseStatementFactory { private final DatabaseReporter reporter; public DatabaseStatementFactory(DatabaseReporter reporter) { this.reporter = reporter; } /** * Creates a new {@link DatabaseStatement}, giving the context of tableName and operation for logging * and reporting purposes. The sql parameter is passed to {@link java.sql.Connection#prepareStatement(String)} * and the parameters are bound with {@link DatabaseStatement#bindParameter(PreparedStatement, int, Object)} */ public DatabaseStatement newStatement(String tableName, String operation, String sql, List parameters) { return new DatabaseStatement(sql, parameters, reporter.table(tableName).operation(operation)); } }