Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java Thu May 28 18:17:39 2009 @@ -19,7 +19,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -59,9 +60,9 @@ dynamicElement.addElement(isNotNullElement); sb.setLength(0); - sb.append(introspectedColumn.getAliasedEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$ + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn, "record.")); //$NON-NLS-1$ isNotNullElement.addElement(new TextElement(sb.toString())); }
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java Thu May 28 18:17:39 2009 @@ -22,7 +22,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -58,9 +59,9 @@ while (iter.hasNext()) { IntrospectedColumn introspectedColumn = iter.next(); - sb.append(introspectedColumn.getAliasedEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$ + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn, "record.")); //$NON-NLS-1$ if (iter.hasNext()) { sb.append(','); Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java Thu May 28 18:17:39 2009 @@ -22,7 +22,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -58,9 +59,9 @@ while (iter.hasNext()) { IntrospectedColumn introspectedColumn = iter.next(); - sb.append(introspectedColumn.getAliasedEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$ + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn, "record.")); //$NON-NLS-1$ if (iter.hasNext()) { sb.append(','); Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java Thu May 28 18:17:39 2009 @@ -20,7 +20,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -71,9 +72,9 @@ dynamicElement.addElement(isNotNullElement); sb.setLength(0); - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); isNotNullElement.addElement(new TextElement(sb.toString())); } @@ -88,9 +89,9 @@ and = true; } - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); answer.addElement(new TextElement(sb.toString())); } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java Thu May 28 18:17:39 2009 @@ -23,7 +23,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -71,9 +72,9 @@ while (iter.hasNext()) { IntrospectedColumn introspectedColumn = iter.next(); - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); if (iter.hasNext()) { sb.append(','); @@ -98,9 +99,9 @@ and = true; } - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); answer.addElement(new TextElement(sb.toString())); } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java Thu May 28 18:17:39 2009 @@ -22,7 +22,8 @@ import org.apache.ibatis.ibator.api.dom.xml.Attribute; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * @@ -60,9 +61,9 @@ while (iter.hasNext()) { IntrospectedColumn introspectedColumn = iter.next(); - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); if (iter.hasNext()) { sb.append(','); @@ -87,9 +88,9 @@ and = true; } - sb.append(introspectedColumn.getEscapedColumnName()); + sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn)); sb.append(" = "); //$NON-NLS-1$ - sb.append(introspectedColumn.getIbatisFormattedParameterClause()); + sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn)); answer.addElement(new TextElement(sb.toString())); } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/db/DatabaseIntrospector.java Thu May 28 18:17:39 2009 @@ -243,6 +243,7 @@ if (fullyQualifiedJavaType != null) { introspectedColumn.setFullyQualifiedJavaType(fullyQualifiedJavaType); + introspectedColumn.setJdbcTypeName(javaTypeResolver.calculateJdbcTypeName(introspectedColumn)); } else { // type cannot be resolved. Check for ignored or overridden boolean warn = true; @@ -261,6 +262,7 @@ // if the type is not supported, then we'll report a warning if (warn) { introspectedColumn.setFullyQualifiedJavaType(FullyQualifiedJavaType.getObjectInstance()); + introspectedColumn.setJdbcTypeName("OTHER"); //$NON-NLS-1$ String warning = Messages.getString("Warning.14", //$NON-NLS-1$ entry.getKey().toString(), @@ -268,7 +270,6 @@ warnings.add(warning); } - } if (ibatorContext.autoDelimitKeywords()) { Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JavaTypeResolverDefaultImpl.java Thu May 28 18:17:39 2009 @@ -37,71 +37,106 @@ public class JavaTypeResolverDefaultImpl implements JavaTypeResolver { protected List<String> warnings; - + protected Properties properties; - + protected IbatorContext ibatorContext; - + protected boolean forceBigDecimals; - - protected Map<Integer, FullyQualifiedJavaType> typeMap; + + protected Map<Integer, JdbcTypeInformation> typeMap; public JavaTypeResolverDefaultImpl() { - super(); + super(); properties = new Properties(); - typeMap = new HashMap<Integer, FullyQualifiedJavaType>(); - - typeMap.put(Types.ARRAY, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.BIGINT, new FullyQualifiedJavaType(Long.class.getName())); - typeMap.put(Types.BINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$ - typeMap.put(Types.BIT, new FullyQualifiedJavaType(Boolean.class.getName())); - typeMap.put(Types.BLOB, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$ - typeMap.put(Types.BOOLEAN, new FullyQualifiedJavaType(Boolean.class.getName())); - typeMap.put(Types.CHAR, new FullyQualifiedJavaType(String.class.getName())); - typeMap.put(Types.CLOB, new FullyQualifiedJavaType(String.class.getName())); - typeMap.put(Types.DATALINK, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.DATE, new FullyQualifiedJavaType(Date.class.getName())); - typeMap.put(Types.DISTINCT, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.DOUBLE, new FullyQualifiedJavaType(Double.class.getName())); - typeMap.put(Types.FLOAT, new FullyQualifiedJavaType(Double.class.getName())); - typeMap.put(Types.INTEGER, new FullyQualifiedJavaType(Integer.class.getName())); - typeMap.put(Types.JAVA_OBJECT, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.LONGVARBINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$ - typeMap.put(Types.LONGVARCHAR, new FullyQualifiedJavaType(String.class.getName())); - typeMap.put(Types.NULL, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.OTHER, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.REAL, new FullyQualifiedJavaType(Float.class.getName())); - typeMap.put(Types.REF, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.SMALLINT, new FullyQualifiedJavaType(Short.class.getName())); - typeMap.put(Types.STRUCT, new FullyQualifiedJavaType(Object.class.getName())); - typeMap.put(Types.TIME, new FullyQualifiedJavaType(Date.class.getName())); - typeMap.put(Types.TIMESTAMP, new FullyQualifiedJavaType(Date.class.getName())); - typeMap.put(Types.TINYINT, new FullyQualifiedJavaType(Byte.class.getName())); - typeMap.put(Types.VARBINARY, new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$ - typeMap.put(Types.VARCHAR, new FullyQualifiedJavaType(String.class.getName())); + typeMap = new HashMap<Integer, JdbcTypeInformation>(); + + typeMap.put(Types.ARRAY, new JdbcTypeInformation("ARRAY", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.BIGINT, new JdbcTypeInformation("BIGINT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Long.class.getName()))); + typeMap.put(Types.BINARY, new JdbcTypeInformation("BINARY", //$NON-NLS-1$ + new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ + typeMap.put(Types.BIT, new JdbcTypeInformation("BIT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Boolean.class.getName()))); + typeMap.put(Types.BLOB, new JdbcTypeInformation("BLOB", //$NON-NLS-1$ + new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ + typeMap.put(Types.BOOLEAN, new JdbcTypeInformation("BOOLEAN", //$NON-NLS-1$ + new FullyQualifiedJavaType(Boolean.class.getName()))); + typeMap.put(Types.CHAR, new JdbcTypeInformation("CHAR", //$NON-NLS-1$ + new FullyQualifiedJavaType(String.class.getName()))); + typeMap.put(Types.CLOB, new JdbcTypeInformation("CLOB", //$NON-NLS-1$ + new FullyQualifiedJavaType(String.class.getName()))); + typeMap.put(Types.DATALINK, new JdbcTypeInformation("DATALINK", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.DATE, new JdbcTypeInformation("DATE", //$NON-NLS-1$ + new FullyQualifiedJavaType(Date.class.getName()))); + typeMap.put(Types.DISTINCT, new JdbcTypeInformation("DISTINCT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.DOUBLE, new JdbcTypeInformation("DOUBLE", //$NON-NLS-1$ + new FullyQualifiedJavaType(Double.class.getName()))); + typeMap.put(Types.FLOAT, new JdbcTypeInformation("FLOAT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Double.class.getName()))); + typeMap.put(Types.INTEGER, new JdbcTypeInformation("INTEGER", //$NON-NLS-1$ + new FullyQualifiedJavaType(Integer.class.getName()))); + typeMap.put(Types.JAVA_OBJECT, new JdbcTypeInformation("JAVA_OBJECT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.LONGVARBINARY, new JdbcTypeInformation("LONGVARBINARY", //$NON-NLS-1$ + new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ + typeMap.put(Types.LONGVARCHAR, new JdbcTypeInformation("LONCVARCHAR", //$NON-NLS-1$ + new FullyQualifiedJavaType(String.class.getName()))); + typeMap.put(Types.NULL, new JdbcTypeInformation("NULL", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.OTHER, new JdbcTypeInformation("OTHER", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.REAL, new JdbcTypeInformation("REAL", //$NON-NLS-1$ + new FullyQualifiedJavaType(Float.class.getName()))); + typeMap.put(Types.REF, new JdbcTypeInformation("REF", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Short.class.getName()))); + typeMap.put(Types.STRUCT, new JdbcTypeInformation("STRUCT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Object.class.getName()))); + typeMap.put(Types.TIME, new JdbcTypeInformation("TIME", //$NON-NLS-1$ + new FullyQualifiedJavaType(Date.class.getName()))); + typeMap.put(Types.TIMESTAMP, new JdbcTypeInformation("TIMESTAMP", //$NON-NLS-1$ + new FullyQualifiedJavaType(Date.class.getName()))); + typeMap.put(Types.TINYINT, new JdbcTypeInformation("TINYINT", //$NON-NLS-1$ + new FullyQualifiedJavaType(Byte.class.getName()))); + typeMap.put(Types.VARBINARY, new JdbcTypeInformation("VARBINARY", //$NON-NLS-1$ + new FullyQualifiedJavaType("byte[]"))); //$NON-NLS-1$ + typeMap.put(Types.VARCHAR, new JdbcTypeInformation("VARCHAR", //$NON-NLS-1$ + new FullyQualifiedJavaType(String.class.getName()))); } public void addConfigurationProperties(Properties properties) { this.properties.putAll(properties); - forceBigDecimals = StringUtility.isTrue(properties - .getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS)); + forceBigDecimals = StringUtility + .isTrue(properties + .getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS)); } /* - * (non-Javadoc) - * @see org.apache.ibatis.ibator.api.JavaTypeResolver#initializeResolvedJavaType(org.apache.ibatis.ibator.internal.db.ColumnDefinition) + * (non-Javadoc) + * + * @see + * org.apache.ibatis.ibator.api.JavaTypeResolver#initializeResolvedJavaType + * (org.apache.ibatis.ibator.internal.db.ColumnDefinition) */ public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) { - FullyQualifiedJavaType answer; - - switch (introspectedColumn.getJdbcType()) { - case Types.DECIMAL: - case Types.NUMERIC: - answer = typeMap.get(introspectedColumn.getJdbcType()); - if (answer == null) { - if (introspectedColumn.getScale() > 0 || introspectedColumn.getLength() > 18 || forceBigDecimals) { - answer = new FullyQualifiedJavaType(BigDecimal.class.getName()); + JdbcTypeInformation jdbcTypeInformation = typeMap + .get(introspectedColumn.getJdbcType()); + + if (jdbcTypeInformation == null) { + switch (introspectedColumn.getJdbcType()) { + case Types.DECIMAL: + case Types.NUMERIC: + if (introspectedColumn.getScale() > 0 + || introspectedColumn.getLength() > 18 + || forceBigDecimals) { + answer = new FullyQualifiedJavaType(BigDecimal.class + .getName()); } else if (introspectedColumn.getLength() > 9) { answer = new FullyQualifiedJavaType(Long.class.getName()); } else if (introspectedColumn.getLength() > 4) { @@ -109,19 +144,52 @@ } else { answer = new FullyQualifiedJavaType(Short.class.getName()); } + break; + + default: + answer = null; + break; } - break; + } else { + answer = jdbcTypeInformation.getFullyQualifiedJavaType(); + } + + return answer; + } - default: - answer = typeMap.get(introspectedColumn.getJdbcType()); - break; + /* + * (non-Javadoc) + * @see org.apache.ibatis.ibator.api.JavaTypeResolver#calculateJdbcTypeName(org.apache.ibatis.ibator.api.IntrospectedColumn) + */ + public String calculateJdbcTypeName(IntrospectedColumn introspectedColumn) { + String answer; + JdbcTypeInformation jdbcTypeInformation = typeMap + .get(introspectedColumn.getJdbcType()); + + if (jdbcTypeInformation == null) { + switch (introspectedColumn.getJdbcType()) { + case Types.DECIMAL: + answer = "DECIMAL"; //$NON-NLS-1$ + break; + case Types.NUMERIC: + answer = "NUMERIC"; //$NON-NLS-1$ + break; + default: + answer = null; + break; + } + } else { + answer = jdbcTypeInformation.getJdbcTypeName(); } return answer; } - - /* (non-Javadoc) - * @see org.apache.ibatis.ibator.api.JavaTypeResolver#setWarnings(java.util.List) + + /* + * (non-Javadoc) + * + * @see + * org.apache.ibatis.ibator.api.JavaTypeResolver#setWarnings(java.util.List) */ public void setWarnings(List<String> warnings) { this.warnings = warnings; @@ -130,4 +198,24 @@ public void setIbatorContext(IbatorContext ibatorContext) { this.ibatorContext = ibatorContext; } + + private static class JdbcTypeInformation { + private String jdbcTypeName; + + private FullyQualifiedJavaType fullyQualifiedJavaType; + + public JdbcTypeInformation(String jdbcTypeName, + FullyQualifiedJavaType fullyQualifiedJavaType) { + this.jdbcTypeName = jdbcTypeName; + this.fullyQualifiedJavaType = fullyQualifiedJavaType; + } + + public String getJdbcTypeName() { + return jdbcTypeName; + } + + public FullyQualifiedJavaType getFullyQualifiedJavaType() { + return fullyQualifiedJavaType; + } + } } Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java Thu May 28 18:17:39 2009 @@ -20,7 +20,7 @@ import java.util.Map; /** - * + * TODO - Delete Me * @author Jeff Butler */ public class JdbcTypeNameTranslator { Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/StringUtility.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/StringUtility.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/StringUtility.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/StringUtility.java Thu May 28 18:17:39 2009 @@ -95,23 +95,6 @@ return "true".equalsIgnoreCase(s); //$NON-NLS-1$ } - public static String escapeStringForIbatis(String s) { - StringTokenizer st = new StringTokenizer(s, "$#", true); //$NON-NLS-1$ - StringBuilder sb = new StringBuilder(); - while (st.hasMoreTokens()) { - String token = st.nextToken(); - if ("$".equals(token)) { //$NON-NLS-1$ - sb.append("$$"); //$NON-NLS-1$ - } else if ("#".equals(token)) { //$NON-NLS-1$ - sb.append("##"); //$NON-NLS-1$ - } else { - sb.append(token); - } - } - - return sb.toString(); - } - public static boolean stringContainsSQLWildcard(String s) { if (s == null) { return false; Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/CaseInsensitiveLikePlugin.java Thu May 28 18:17:39 2009 @@ -27,6 +27,7 @@ import org.apache.ibatis.ibator.api.dom.java.Method; import org.apache.ibatis.ibator.api.dom.java.Parameter; import org.apache.ibatis.ibator.api.dom.java.TopLevelClass; +import org.apache.ibatis.ibator.generator.ibatis2.Ibatis2FormattingUtilities; /** * This plugin demonstrates adding methods to the example class to @@ -94,7 +95,7 @@ sb.setLength(0); sb.append("addCriterion(\"upper("); //$NON-NLS-1$ - sb.append(introspectedColumn.getAliasedActualColumnName()); + sb.append(Ibatis2FormattingUtilities.getAliasedActualColumnName(introspectedColumn)); sb.append(") like\", value.toUpperCase(), \""); //$NON-NLS-1$ sb.append(introspectedColumn.getJavaProperty()); sb.append("\");"); //$NON-NLS-1$ Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/SqlMapConfigPlugin.java URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/SqlMapConfigPlugin.java?rev=779706&r1=779705&r2=779706&view=diff ============================================================================== --- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/SqlMapConfigPlugin.java (original) +++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/SqlMapConfigPlugin.java Thu May 28 18:17:39 2009 @@ -26,13 +26,13 @@ import org.apache.ibatis.ibator.api.dom.xml.Document; import org.apache.ibatis.ibator.api.dom.xml.TextElement; import org.apache.ibatis.ibator.api.dom.xml.XmlElement; -import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants; +import org.apache.ibatis.ibator.generator.XmlConstants; import org.apache.ibatis.ibator.internal.util.StringUtility; import org.apache.ibatis.ibator.internal.util.messages.Messages; /** * This plugin generates an SqlMapConfig file containing sqlMap entries for - * SQL maps generated by ibator. This demonstrates hooking into the ibator + * SQL maps generated by Ibator. This demonstrates hooking into the Ibator * code generation lifecycle and generating additional XML files. * <p> * This plugin accepts three properties: @@ -82,8 +82,8 @@ @Override public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles() { - Document document = new Document(XmlConstants.SQL_MAP_CONFIG_PUBLIC_ID, - XmlConstants.SQL_MAP_CONFIG_SYSTEM_ID); + Document document = new Document(XmlConstants.IBATIS2_SQL_MAP_CONFIG_PUBLIC_ID, + XmlConstants.IBATIS2_SQL_MAP_CONFIG_SYSTEM_ID); XmlElement root = new XmlElement("sqlMapConfig"); //$NON-NLS-1$ document.setRootElement(root);
