de.akquinet.jbosscc.guttenbase.configuration.impl.OracleTargetDatabaseConfiguration Maven / Gradle / Ivy
The newest version!
package de.akquinet.jbosscc.guttenbase.configuration.impl;
import de.akquinet.jbosscc.guttenbase.hints.TableOrderHint;
import de.akquinet.jbosscc.guttenbase.meta.TableMetaData;
import de.akquinet.jbosscc.guttenbase.repository.ConnectorRepository;
import de.akquinet.jbosscc.guttenbase.tools.ScriptExecutorTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
/**
* Implementation for Oracle data base.
*
*
* © 2012-2034 akquinet tech@spree
*
*
* @author M. Dahm
*/
public class OracleTargetDatabaseConfiguration extends DefaultTargetDatabaseConfiguration {
private static final Logger LOG = LoggerFactory.getLogger(OracleTargetDatabaseConfiguration.class);
public OracleTargetDatabaseConfiguration(final ConnectorRepository connectorRepository) {
super(connectorRepository);
}
/**
* {@inheritDoc}
*/
@Override
public void initializeTargetConnection(final Connection connection, final String connectorId) throws SQLException {
if (connection.getAutoCommit()) {
connection.setAutoCommit(false);
}
setReferentialIntegrity(connection, connectorId, getTableMetaData(connectorId), false);
}
/**
* {@inheritDoc}
*/
@Override
public void finalizeTargetConnection(final Connection connection, final String connectorId) throws SQLException {
setReferentialIntegrity(connection, connectorId, getTableMetaData(connectorId), true);
}
private List getTableMetaData(final String connectorId) {
return TableOrderHint.getSortedTables(_connectorRepository, connectorId);
}
private void setReferentialIntegrity(final Connection connection, final String connectorId, final List tableMetaDatas,
final boolean enable) throws SQLException {
final String tablesList = createTablesList(tableMetaDatas);
if (!"".equals(tablesList)) {
final String schema = _connectorRepository.getConnectionInfo(connectorId).getSchema();
/* I want to disable all constraints in tables that reference the tables that I will update. */
final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy