Skip to content

Commit

Permalink
Use Spring helper classes for JDBC dependent operations
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Dec 29, 2011
1 parent bc3a320 commit 2c5c303
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 782 deletions.
Expand Up @@ -29,7 +29,7 @@
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;

/**
* Represents a column in the database model.
Expand Down Expand Up @@ -446,8 +446,8 @@ public Object getParsedDefaultValue() {
case Types.BIT:
return ConvertUtils.convert(defaultValue, Boolean.class);
default:
if (Jdbc3Utils.supportsJava14JdbcTypes()
&& (typeCode == Jdbc3Utils.determineBooleanTypeCode())) {
if (JdbcUtils.supportsJava14JdbcTypes()
&& (typeCode == JdbcUtils.determineBooleanTypeCode())) {
return ConvertUtils.convert(defaultValue, Boolean.class);
}
break;
Expand Down
Expand Up @@ -24,7 +24,7 @@
import java.util.HashSet;
import java.util.Set;

import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;

/**
* A class that maps SQL type names to their JDBC type ID found in
Expand Down Expand Up @@ -140,10 +140,10 @@ public abstract class TypeMap
registerJdbcType(Types.VARCHAR, VARCHAR, JdbcTypeCategoryEnum.TEXTUAL);

// only available in JDK 1.4 and above:
if (Jdbc3Utils.supportsJava14JdbcTypes())
if (JdbcUtils.supportsJava14JdbcTypes())
{
registerJdbcType(Jdbc3Utils.determineBooleanTypeCode(), BOOLEAN, JdbcTypeCategoryEnum.NUMERIC);
registerJdbcType(Jdbc3Utils.determineDatalinkTypeCode(), DATALINK, JdbcTypeCategoryEnum.SPECIAL);
registerJdbcType(JdbcUtils.determineBooleanTypeCode(), BOOLEAN, JdbcTypeCategoryEnum.NUMERIC);
registerJdbcType(JdbcUtils.determineDatalinkTypeCode(), DATALINK, JdbcTypeCategoryEnum.SPECIAL);
}

// Torque/Turbine extensions which we only support when reading from an XML schema
Expand Down
Expand Up @@ -27,7 +27,7 @@
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.ConvertUtils;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;

/**
* Helper class for dealing with default values, e.g. converting them to other
Expand Down Expand Up @@ -77,8 +77,8 @@ public String convert(String defaultValue, int originalTypeCode, int targetTypeC
}
break;
default:
if (Jdbc3Utils.supportsJava14JdbcTypes()
&& (originalTypeCode == Jdbc3Utils.determineBooleanTypeCode())) {
if (JdbcUtils.supportsJava14JdbcTypes()
&& (originalTypeCode == JdbcUtils.determineBooleanTypeCode())) {
result = convertBoolean(defaultValue, targetTypeCode).toString();
}
break;
Expand Down Expand Up @@ -107,7 +107,7 @@ private Object convertBoolean(String defaultValue, int targetTypeCode) {
}

if ((targetTypeCode == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (targetTypeCode == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (targetTypeCode == JdbcUtils
.determineBooleanTypeCode()))) {
result = value;
} else if (TypeMap.isNumericType(targetTypeCode)) {
Expand Down
Expand Up @@ -36,7 +36,7 @@
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand All @@ -52,7 +52,7 @@ public Db2Builder(Log log, IDatabasePlatform platform) {
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down
Expand Up @@ -32,7 +32,7 @@
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand All @@ -48,7 +48,7 @@ public DerbyBuilder(Log log, IDatabasePlatform platform) {
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down
Expand Up @@ -33,7 +33,7 @@
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand Down Expand Up @@ -175,7 +175,7 @@ public String getSelectLastIdentityValues(Table table) {
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down
Expand Up @@ -33,7 +33,7 @@
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand Down Expand Up @@ -61,7 +61,7 @@ public void createTable(Table table, StringBuilder ddl) {
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down
Expand Up @@ -50,7 +50,7 @@
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand Down Expand Up @@ -179,7 +179,7 @@ protected String getValueAsString(Column column, Object value) {
protected String getNativeDefaultValue(Column column) {
// Sql Server wants BIT default values as 0 or 1
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down
Expand Up @@ -42,7 +42,7 @@
import org.jumpmind.db.model.Table;
import org.jumpmind.db.model.TypeMap;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand Down Expand Up @@ -244,7 +244,7 @@ protected void printDefaultValue(Object defaultValue, int typeCode, StringBuilde
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down

This file was deleted.

Expand Up @@ -28,6 +28,7 @@
import org.jumpmind.db.platform.DatabasePlatformSettings;
import org.jumpmind.db.sql.jdbc.JdbcSqlTemplate;
import org.jumpmind.log.Log;
import org.springframework.jdbc.support.lob.OracleLobHandler;

/*
* The platform for Oracle 8.
Expand Down
Expand Up @@ -43,7 +43,7 @@
import org.jumpmind.db.model.IIndex;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.platform.AbstractDdlBuilder;
import org.jumpmind.db.util.Jdbc3Utils;
import org.jumpmind.db.sql.jdbc.JdbcUtils;
import org.jumpmind.log.Log;

/*
Expand Down Expand Up @@ -86,7 +86,7 @@ protected void writeColumn(Table table, Column column, StringBuilder ddl) {
@Override
protected String getNativeDefaultValue(Column column) {
if ((column.getTypeCode() == Types.BIT)
|| (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils
|| (JdbcUtils.supportsJava14JdbcTypes() && (column.getTypeCode() == JdbcUtils
.determineBooleanTypeCode()))) {
return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(),
Types.SMALLINT).toString();
Expand Down

0 comments on commit 2c5c303

Please sign in to comment.