You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ibatis.apache.org by jg...@apache.org on 2008/10/10 22:08:12 UTC
svn commit: r703569 [6/6] - in /ibatis/trunk/java/tools/ibator/core: build/
devlib/ doc/ src/org/apache/ibatis/ibator/api/
src/org/apache/ibatis/ibator/config/ src/org/apache/ibatis/ibator/config/xml/
src/org/apache/ibatis/ibator/generator/ src/org/apa...
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithBLOBsElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import java.util.Iterator;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.OutputUtilities;
+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;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByExampleWithBLOBsElementGenerator extends
+ XmlElementGeneratorBaseImpl {
+
+ public UpdateByExampleWithBLOBsElementGenerator() {
+ super();
+ }
+
+ public void addElements(XmlElement parentElement) {
+ XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+ answer.addAttribute(new Attribute(
+ "id", XmlConstants.UPDATE_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID)); //$NON-NLS-1$
+
+ ibatorContext.getCommentGenerator().addComment(answer);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("update "); //$NON-NLS-1$
+ sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for first column
+ sb.setLength(0);
+ sb.append("set "); //$NON-NLS-1$
+
+ Iterator<IntrospectedColumn> iter = introspectedTable.getAllColumns().iterator();
+ while (iter.hasNext()) {
+ IntrospectedColumn introspectedColumn = iter.next();
+
+ sb.append(introspectedColumn.getAliasedEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+
+ if (iter.hasNext()) {
+ sb.append(',');
+ }
+
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for the next column
+ if (iter.hasNext()) {
+ sb.setLength(0);
+ OutputUtilities.xmlIndent(sb, 1);
+ }
+ }
+
+ XmlElement isParameterPresentElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresentElement);
+
+ XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+ includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+ table.getSqlMapNamespace() + "." + XmlConstants.EXAMPLE_WHERE_CLAUSE_ID)); //$NON-NLS-1$
+ isParameterPresentElement.addElement(includeElement);
+
+ if (ibatorContext.getPlugins().sqlMapUpdateByExampleWithBLOBsElementGenerated(answer, introspectedTable)) {
+ parentElement.addElement(answer);
+ }
+ }
+}
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleWithoutBLOBsElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import java.util.Iterator;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.OutputUtilities;
+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;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByExampleWithoutBLOBsElementGenerator extends
+ XmlElementGeneratorBaseImpl {
+
+ public UpdateByExampleWithoutBLOBsElementGenerator() {
+ super();
+ }
+
+ public void addElements(XmlElement parentElement) {
+ XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+ answer.addAttribute(new Attribute(
+ "id", XmlConstants.UPDATE_BY_EXAMPLE_STATEMENT_ID)); //$NON-NLS-1$
+
+ ibatorContext.getCommentGenerator().addComment(answer);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("update "); //$NON-NLS-1$
+ sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for first column
+ sb.setLength(0);
+ sb.append("set "); //$NON-NLS-1$
+
+ Iterator<IntrospectedColumn> iter = introspectedTable.getNonBLOBColumns().iterator();
+ while (iter.hasNext()) {
+ IntrospectedColumn introspectedColumn = iter.next();
+
+ sb.append(introspectedColumn.getAliasedEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+
+ if (iter.hasNext()) {
+ sb.append(',');
+ }
+
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for the next column
+ if (iter.hasNext()) {
+ sb.setLength(0);
+ OutputUtilities.xmlIndent(sb, 1);
+ }
+ }
+
+ XmlElement isParameterPresentElement =
+ new XmlElement("isParameterPresent"); //$NON-NLS-1$
+ answer.addElement(isParameterPresentElement);
+
+ XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+ includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+ table.getSqlMapNamespace() + "." + XmlConstants.EXAMPLE_WHERE_CLAUSE_ID)); //$NON-NLS-1$
+ isParameterPresentElement.addElement(includeElement);
+
+ if (ibatorContext.getPlugins().sqlMapUpdateByExampleWithoutBLOBsElementGenerated(answer, introspectedTable)) {
+ parentElement.addElement(answer);
+ }
+ }
+}
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeySelectiveElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+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;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByPrimaryKeySelectiveElementGenerator extends
+ XmlElementGeneratorBaseImpl {
+
+ public UpdateByPrimaryKeySelectiveElementGenerator() {
+ super();
+ }
+
+ public void addElements(XmlElement parentElement) {
+ XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+ answer.addAttribute(new Attribute(
+ "id", XmlConstants.UPDATE_BY_PRIMARY_KEY_SELECTIVE_STATEMENT_ID)); //$NON-NLS-1$
+
+ FullyQualifiedJavaType parameterType;
+
+ if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+ parameterType = introspectedTable.getRecordWithBLOBsType();
+ } else {
+ parameterType = introspectedTable.getBaseRecordType();
+ }
+
+ answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+ parameterType.getFullyQualifiedName()));
+
+ ibatorContext.getCommentGenerator().addComment(answer);
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("update "); //$NON-NLS-1$
+ sb.append(table.getFullyQualifiedTableNameAtRuntime());
+ answer.addElement(new TextElement(sb.toString()));
+
+ XmlElement dynamicElement = new XmlElement("dynamic"); //$NON-NLS-1$
+ dynamicElement.addAttribute(new Attribute("prepend", "set")); //$NON-NLS-1$ //$NON-NLS-2$
+ answer.addElement(dynamicElement);
+
+ for (IntrospectedColumn introspectedColumn : introspectedTable.getNonPrimaryKeyColumns()) {
+ XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+ isNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+ isNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+ dynamicElement.addElement(isNotNullElement);
+
+ sb.setLength(0);
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+
+ isNotNullElement.addElement(new TextElement(sb.toString()));
+ }
+
+ boolean and = false;
+ for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
+ sb.setLength(0);
+ if (and) {
+ sb.append(" and "); //$NON-NLS-1$
+ } else {
+ sb.append("where "); //$NON-NLS-1$
+ and = true;
+ }
+
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+ answer.addElement(new TextElement(sb.toString()));
+ }
+
+
+ if (ibatorContext.getPlugins().sqlMapUpdateByPrimaryKeySelectiveElementGenerated(answer, introspectedTable)) {
+ parentElement.addElement(answer);
+ }
+ }
+}
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithBLOBsElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import java.util.Iterator;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.OutputUtilities;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+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;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByPrimaryKeyWithBLOBsElementGenerator extends
+ XmlElementGeneratorBaseImpl {
+
+ public UpdateByPrimaryKeyWithBLOBsElementGenerator() {
+ super();
+ }
+
+ public void addElements(XmlElement parentElement) {
+ XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+ answer.addAttribute(new Attribute(
+ "id", XmlConstants.UPDATE_BY_PRIMARY_KEY_WITH_BLOBS_STATEMENT_ID)); //$NON-NLS-1$
+
+ FullyQualifiedJavaType parameterType;
+
+ if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+ parameterType = introspectedTable.getRecordWithBLOBsType();
+ } else {
+ parameterType = introspectedTable.getBaseRecordType();
+ }
+
+ answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+ parameterType.getFullyQualifiedName()));
+
+ ibatorContext.getCommentGenerator().addComment(answer);
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("update "); //$NON-NLS-1$
+ sb.append(table.getFullyQualifiedTableNameAtRuntime());
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for first column
+ sb.setLength(0);
+ sb.append("set "); //$NON-NLS-1$
+
+ Iterator<IntrospectedColumn> iter = introspectedTable.getNonPrimaryKeyColumns().iterator();
+ while (iter.hasNext()) {
+ IntrospectedColumn introspectedColumn = iter.next();
+
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+
+ if (iter.hasNext()) {
+ sb.append(',');
+ }
+
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for the next column
+ if (iter.hasNext()) {
+ sb.setLength(0);
+ OutputUtilities.xmlIndent(sb, 1);
+ }
+ }
+
+ boolean and = false;
+ for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
+ sb.setLength(0);
+ if (and) {
+ sb.append(" and "); //$NON-NLS-1$
+ } else {
+ sb.append("where "); //$NON-NLS-1$
+ and = true;
+ }
+
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+ answer.addElement(new TextElement(sb.toString()));
+ }
+
+
+ if (ibatorContext.getPlugins().sqlMapUpdateByPrimaryKeyWithBLOBsElementGenerated(answer, introspectedTable)) {
+ parentElement.addElement(answer);
+ }
+ }
+}
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByPrimaryKeyWithoutBLOBsElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import java.util.Iterator;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.OutputUtilities;
+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;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public class UpdateByPrimaryKeyWithoutBLOBsElementGenerator extends
+ XmlElementGeneratorBaseImpl {
+
+ public UpdateByPrimaryKeyWithoutBLOBsElementGenerator() {
+ super();
+ }
+
+ public void addElements(XmlElement parentElement) {
+ XmlElement answer = new XmlElement("update"); //$NON-NLS-1$
+ FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+ answer.addAttribute(new Attribute(
+ "id", XmlConstants.UPDATE_BY_PRIMARY_KEY_STATEMENT_ID)); //$NON-NLS-1$
+ answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+ introspectedTable.getBaseRecordType().getFullyQualifiedName()));
+
+ ibatorContext.getCommentGenerator().addComment(answer);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("update "); //$NON-NLS-1$
+ sb.append(table.getFullyQualifiedTableNameAtRuntime());
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for first column
+ sb.setLength(0);
+ sb.append("set "); //$NON-NLS-1$
+
+ Iterator<IntrospectedColumn> iter = introspectedTable.getBaseColumns().iterator();
+ while (iter.hasNext()) {
+ IntrospectedColumn introspectedColumn = iter.next();
+
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+
+ if (iter.hasNext()) {
+ sb.append(',');
+ }
+
+ answer.addElement(new TextElement(sb.toString()));
+
+ // set up for the next column
+ if (iter.hasNext()) {
+ sb.setLength(0);
+ OutputUtilities.xmlIndent(sb, 1);
+ }
+ }
+
+ boolean and = false;
+ for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
+ sb.setLength(0);
+ if (and) {
+ sb.append(" and "); //$NON-NLS-1$
+ } else {
+ sb.append("where "); //$NON-NLS-1$
+ and = true;
+ }
+
+ sb.append(introspectedColumn.getEscapedColumnName());
+ sb.append(" = "); //$NON-NLS-1$
+ sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+ answer.addElement(new TextElement(sb.toString()));
+ }
+
+ if (ibatorContext.getPlugins().sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(answer, introspectedTable)) {
+ parentElement.addElement(answer);
+ }
+ }
+}
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import org.apache.ibatis.ibator.api.dom.xml.XmlElement;
+import org.apache.ibatis.ibator.generator.AbstractGenerator;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public interface XmlElementGenerator extends AbstractGenerator {
+ void addElements(XmlElement parentElement);
+}
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGeneratorBaseImpl.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGeneratorBaseImpl.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGeneratorBaseImpl.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/XmlElementGeneratorBaseImpl.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements;
+
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+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.config.GeneratedKey;
+import org.apache.ibatis.ibator.generator.AbstractGeneratorImpl;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ *
+ * @author Jeff Butler
+ *
+ */
+public abstract class XmlElementGeneratorBaseImpl extends AbstractGeneratorImpl implements XmlElementGenerator {
+
+ public XmlElementGeneratorBaseImpl() {
+ super();
+ }
+
+ /**
+ * This method should return an XmlElement for the select key used to
+ * automatically generate keys.
+ *
+ * @param columnDefinition
+ * the column related to the select key statement
+ * @param generatedKey
+ * the generated key for the current table
+ * @return the selectKey element
+ */
+ protected XmlElement getSelectKey(IntrospectedColumn introspectedColumn, GeneratedKey generatedKey) {
+ String identityColumnType = introspectedColumn
+ .getFullyQualifiedJavaType().getFullyQualifiedName();
+
+ XmlElement answer = new XmlElement("selectKey"); //$NON-NLS-1$
+ answer.addAttribute(new Attribute("resultClass", identityColumnType)); //$NON-NLS-1$
+ answer.addAttribute(new Attribute(
+ "keyProperty", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+ if(StringUtility.stringHasValue(generatedKey.getType())) {
+ answer.addAttribute(new Attribute("type", generatedKey.getType())); //$NON-NLS-1$
+ }
+ answer.addElement(new TextElement(generatedKey.getRuntimeSqlStatement()));
+
+ return answer;
+ }
+}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorObjectFactory.java Fri Oct 10 13:08:10 2008
@@ -18,24 +18,17 @@
import java.util.List;
import org.apache.ibatis.ibator.api.CommentGenerator;
-import org.apache.ibatis.ibator.api.DAOGenerator;
import org.apache.ibatis.ibator.api.FullyQualifiedTable;
import org.apache.ibatis.ibator.api.IbatorPlugin;
import org.apache.ibatis.ibator.api.IntrospectedTable;
-import org.apache.ibatis.ibator.api.JavaModelGenerator;
import org.apache.ibatis.ibator.api.JavaTypeResolver;
-import org.apache.ibatis.ibator.api.SqlMapGenerator;
import org.apache.ibatis.ibator.config.CommentGeneratorConfiguration;
-import org.apache.ibatis.ibator.config.DAOGeneratorConfiguration;
import org.apache.ibatis.ibator.config.IbatorContext;
import org.apache.ibatis.ibator.config.IbatorPluginConfiguration;
-import org.apache.ibatis.ibator.config.JavaModelGeneratorConfiguration;
import org.apache.ibatis.ibator.config.JavaTypeResolverConfiguration;
-import org.apache.ibatis.ibator.config.SqlMapGeneratorConfiguration;
import org.apache.ibatis.ibator.config.TableConfiguration;
-import org.apache.ibatis.ibator.internal.db.ColumnDefinitions;
-import org.apache.ibatis.ibator.internal.db.IntrospectedTableDefaultImpl;
-import org.apache.ibatis.ibator.internal.util.StringUtility;
+import org.apache.ibatis.ibator.generator.ibatis2.IntrospectedTableIbatis2Impl;
+import org.apache.ibatis.ibator.internal.types.JavaTypeResolverDefaultImpl;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
/**
@@ -98,7 +91,7 @@
if (config != null && config.getConfigurationType() != null) {
type = config.getConfigurationType();
} else {
- type = context.getGeneratorSet().getJavaTypeResolverType();
+ type = JavaTypeResolverDefaultImpl.class.getName();
}
JavaTypeResolver answer = (JavaTypeResolver) createObject(type);
@@ -120,68 +113,6 @@
return ibatorPlugin;
}
- public static SqlMapGenerator createSqlMapGenerator(IbatorContext context,
- List<String> warnings) {
-
- SqlMapGeneratorConfiguration config = context.getSqlMapGeneratorConfiguration();
- String type;
-
- if (config.getConfigurationType() != null) {
- type = config.getConfigurationType();
- } else {
- type = context.getGeneratorSet().getSqlMapGeneratorType();
- }
-
- SqlMapGenerator answer = (SqlMapGenerator) createObject(type);
- answer.setWarnings(warnings);
-
- answer.addConfigurationProperties(config.getProperties());
- answer.setIbatorContext(context);
-
- return answer;
- }
-
- public static JavaModelGenerator createJavaModelGenerator(IbatorContext context,
- List<String> warnings) {
-
- JavaModelGeneratorConfiguration config = context.getJavaModelGeneratorConfiguration();
- String type;
-
- if (config.getConfigurationType() != null) {
- type = config.getConfigurationType();
- } else {
- type = context.getGeneratorSet().getJavaModelGeneratorType();
- }
-
- JavaModelGenerator answer = (JavaModelGenerator) createObject(type);
- answer.setWarnings(warnings);
-
- answer.addConfigurationProperties(config.getProperties());
- answer.setIbatorContext(context);
-
- return answer;
- }
-
- public static DAOGenerator createDAOGenerator(IbatorContext context,
- List<String> warnings) {
-
- DAOGeneratorConfiguration config = context.getDaoGeneratorConfiguration();
-
- if (config == null) {
- return null;
- }
-
- String type = context.getGeneratorSet().translateDAOGeneratorType(config.getConfigurationType());
-
- DAOGenerator answer = (DAOGenerator) createObject(type);
- answer.setWarnings(warnings);
-
- answer.addConfigurationProperties(config.getProperties());
- answer.setIbatorContext(context);
-
- return answer;
- }
-
public static CommentGenerator createCommentGenerator(IbatorContext context) {
CommentGeneratorConfiguration config = context.getCommentGeneratorConfiguration();
@@ -203,16 +134,14 @@
return answer;
}
- public static IntrospectedTable createIntrospectedTable(TableConfiguration tableConfiguration, ColumnDefinitions columnDefinitions,
+ public static IntrospectedTable createIntrospectedTable(TableConfiguration tableConfiguration,
FullyQualifiedTable table, IbatorContext ibatorContext) {
- String type = ibatorContext.getIntrospectedTableImplementation();
- if (!StringUtility.stringHasValue(type)) {
- type = IntrospectedTableDefaultImpl.class.getName();
- }
+ // TODO - this method should decide what implementation based on some
+ // configuration setting (getting ready for iBATIS 3)
+ String type = IntrospectedTableIbatis2Impl.class.getName();
IntrospectedTable answer = (IntrospectedTable) createObject(type);
- answer.setColumnDefinitions(columnDefinitions);
answer.setFullyQualifiedTable(table);
answer.setIbatorContext(ibatorContext);
answer.setTableConfiguration(tableConfiguration);
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorPluginAggregator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorPluginAggregator.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorPluginAggregator.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/IbatorPluginAggregator.java Fri Oct 10 13:08:10 2008
@@ -22,6 +22,7 @@
import org.apache.ibatis.ibator.api.GeneratedJavaFile;
import org.apache.ibatis.ibator.api.GeneratedXmlFile;
import org.apache.ibatis.ibator.api.IbatorPlugin;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
import org.apache.ibatis.ibator.api.IntrospectedTable;
import org.apache.ibatis.ibator.api.dom.java.Field;
import org.apache.ibatis.ibator.api.dom.java.Interface;
@@ -30,7 +31,6 @@
import org.apache.ibatis.ibator.api.dom.xml.Document;
import org.apache.ibatis.ibator.api.dom.xml.XmlElement;
import org.apache.ibatis.ibator.config.IbatorContext;
-import org.apache.ibatis.ibator.internal.db.ColumnDefinition;
/**
* This class is for internal use only. It contains a list of plugins for the
@@ -861,11 +861,11 @@
return rc;
}
- public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass, ColumnDefinition columnDefinition, IntrospectedTable introspectedTable) {
+ public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable) {
boolean rc = true;
for (IbatorPlugin plugin : plugins) {
- if (!plugin.modelFieldGenerated(field, topLevelClass, columnDefinition, introspectedTable)) {
+ if (!plugin.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable)) {
rc = false;
break;
}
@@ -874,11 +874,11 @@
return rc;
}
- public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass, ColumnDefinition columnDefinition, IntrospectedTable introspectedTable) {
+ public boolean modelGetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable) {
boolean rc = true;
for (IbatorPlugin plugin : plugins) {
- if (!plugin.modelGetterMethodGenerated(method, topLevelClass, columnDefinition, introspectedTable)) {
+ if (!plugin.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable)) {
rc = false;
break;
}
@@ -887,11 +887,11 @@
return rc;
}
- public boolean modelSetterMethodGenerated(Method method, TopLevelClass topLevelClass, ColumnDefinition columnDefinition, IntrospectedTable introspectedTable) {
+ public boolean modelSetterMethodGenerated(Method method, TopLevelClass topLevelClass, IntrospectedColumn introspectedColumn, IntrospectedTable introspectedTable) {
boolean rc = true;
for (IbatorPlugin plugin : plugins) {
- if (!plugin.modelSetterMethodGenerated(method, topLevelClass, columnDefinition, introspectedTable)) {
+ if (!plugin.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable)) {
rc = false;
break;
}
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=703569&r1=703568&r2=703569&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 Fri Oct 10 13:08:10 2008
@@ -28,16 +28,16 @@
import java.util.regex.Pattern;
import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
import org.apache.ibatis.ibator.api.IntrospectedTable;
import org.apache.ibatis.ibator.api.JavaTypeResolver;
import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
-import org.apache.ibatis.ibator.config.IbatorContext;
import org.apache.ibatis.ibator.config.ColumnOverride;
import org.apache.ibatis.ibator.config.GeneratedKey;
+import org.apache.ibatis.ibator.config.IbatorContext;
import org.apache.ibatis.ibator.config.PropertyRegistry;
import org.apache.ibatis.ibator.config.TableConfiguration;
import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
-import org.apache.ibatis.ibator.internal.types.ResolvedJavaType;
import org.apache.ibatis.ibator.internal.util.JavaBeansUtil;
import org.apache.ibatis.ibator.internal.util.StringUtility;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
@@ -62,7 +62,7 @@
this.warnings = warnings;
}
- private void calculatePrimaryKey(FullyQualifiedTable table, ColumnDefinitions columnDefinitions) {
+ private void calculatePrimaryKey(FullyQualifiedTable table, IntrospectedTable introspectedTable) {
ResultSet rs = null;
try {
@@ -79,7 +79,7 @@
while (rs.next()) {
String columnName = rs.getString("COLUMN_NAME"); //$NON-NLS-1$
- columnDefinitions.addPrimaryKeyColumn(columnName);
+ introspectedTable.addPrimaryKeyColumn(columnName);
}
} catch (SQLException e) {
// ignore the primary key if there's any error
@@ -144,7 +144,7 @@
public List<IntrospectedTable> introspectTables(TableConfiguration tc) throws SQLException {
// get the raw columns from the DB
- Map<ActualTableName, List<ColumnDefinition>> columns = getColumns(tc);
+ Map<ActualTableName, List<IntrospectedColumn>> columns = getColumns(tc);
if (columns.isEmpty()) {
warnings.add(Messages.getString("Warning.19", tc.getCatalog(), //$NON-NLS-1$
@@ -189,12 +189,12 @@
* @param tc
* @param columns
*/
- private void removeIgnoredColumns(TableConfiguration tc, Map<ActualTableName, List<ColumnDefinition>> columns) {
- for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
- Iterator<ColumnDefinition> tableColumns = (entry.getValue()).iterator();
+ private void removeIgnoredColumns(TableConfiguration tc, Map<ActualTableName, List<IntrospectedColumn>> columns) {
+ for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
+ Iterator<IntrospectedColumn> tableColumns = (entry.getValue()).iterator();
while (tableColumns.hasNext()) {
- ColumnDefinition cd = tableColumns.next();
- if (tc.isColumnIgnored(cd.getActualColumnName())) {
+ IntrospectedColumn introspectedColumn = tableColumns.next();
+ if (tc.isColumnIgnored(introspectedColumn.getActualColumnName())) {
tableColumns.remove();
}
}
@@ -202,7 +202,7 @@
}
private void calculateExtraColumnInformation(TableConfiguration tc,
- Map<ActualTableName, List<ColumnDefinition>> columns) {
+ Map<ActualTableName, List<IntrospectedColumn>> columns) {
Pattern pattern = null;
String replaceString = null;
if (tc.getColumnRenamingRule() != null) {
@@ -211,30 +211,35 @@
replaceString = replaceString == null ? "" : replaceString;//$NON-NLS-1$
}
- for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
- for (ColumnDefinition cd : entry.getValue()) {
+ for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
+ for (IntrospectedColumn introspectedColumn : entry.getValue()) {
String calculatedColumnName;
if (pattern == null) {
- calculatedColumnName = cd.getActualColumnName();
+ calculatedColumnName = introspectedColumn.getActualColumnName();
} else {
- Matcher matcher = pattern.matcher(cd.getActualColumnName());
+ Matcher matcher = pattern.matcher(introspectedColumn.getActualColumnName());
calculatedColumnName = matcher.replaceAll(replaceString);
}
if (StringUtility.isTrue(tc.getProperty(PropertyRegistry.TABLE_USE_ACTUAL_COLUMN_NAMES))) {
- cd.setJavaProperty(JavaBeansUtil.getValidPropertyName(calculatedColumnName));
+ introspectedColumn.setJavaProperty(JavaBeansUtil.getValidPropertyName(calculatedColumnName));
} else {
- cd.setJavaProperty(JavaBeansUtil.getCamelCaseString(calculatedColumnName, false));
+ introspectedColumn.setJavaProperty(JavaBeansUtil.getCamelCaseString(calculatedColumnName, false));
}
- if (!javaTypeResolver.initializeResolvedJavaType(cd)) {
+ FullyQualifiedJavaType fullyQualifiedJavaType =
+ javaTypeResolver.calculateJavaType(introspectedColumn);
+
+ if (fullyQualifiedJavaType != null) {
+ introspectedColumn.setFullyQualifiedJavaType(fullyQualifiedJavaType);
+ } else {
// type cannot be resolved. Check for ignored or overridden
boolean warn = true;
- if (tc.isColumnIgnored(cd.getActualColumnName())) {
+ if (tc.isColumnIgnored(introspectedColumn.getActualColumnName())) {
warn = false;
}
- ColumnOverride co = tc.getColumnOverride(cd.getActualColumnName());
+ ColumnOverride co = tc.getColumnOverride(introspectedColumn.getActualColumnName());
if (co != null) {
if (StringUtility.stringHasValue(co.getJavaType())
&& StringUtility.stringHasValue(co.getJavaType())) {
@@ -244,14 +249,11 @@
// if the type is not supported, then we'll report a warning
if (warn) {
- ResolvedJavaType type = new ResolvedJavaType();
- type.setJdbcTypeName("OTHER"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
- cd.setResolvedJavaType(type);
+ introspectedColumn.setFullyQualifiedJavaType(FullyQualifiedJavaType.getObjectInstance());
warnings.add(Messages.getString("Warning.14", //$NON-NLS-1$
entry.getKey().toString(),
- cd.getActualColumnName()));
+ introspectedColumn.getActualColumnName()));
}
}
@@ -260,57 +262,57 @@
}
private void calculateIdentityColumns(TableConfiguration tc,
- Map<ActualTableName, List<ColumnDefinition>> columns) {
- for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
- for (ColumnDefinition cd : entry.getValue()) {
+ Map<ActualTableName, List<IntrospectedColumn>> columns) {
+ for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
+ for (IntrospectedColumn introspectedColumn : entry.getValue()) {
if (tc.getGeneratedKey() != null
&& tc.getGeneratedKey().isIdentity()) {
- if (cd.isColumnNameDelimited()) {
- if (cd.getActualColumnName().equals(tc.getGeneratedKey().getColumn())) {
- cd.setIdentity(true);
+ if (introspectedColumn.isColumnNameDelimited()) {
+ if (introspectedColumn.getActualColumnName().equals(tc.getGeneratedKey().getColumn())) {
+ introspectedColumn.setIdentity(true);
}
} else {
- if (cd.getActualColumnName().equalsIgnoreCase(tc.getGeneratedKey().getColumn())) {
- cd.setIdentity(true);
+ if (introspectedColumn.getActualColumnName().equalsIgnoreCase(tc.getGeneratedKey().getColumn())) {
+ introspectedColumn.setIdentity(true);
}
}
} else {
- cd.setIdentity(false);
+ introspectedColumn.setIdentity(false);
}
}
}
}
private void applyColumnOverrides(TableConfiguration tc,
- Map<ActualTableName, List<ColumnDefinition>> columns) {
- for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
- for (ColumnDefinition cd : entry.getValue()) {
- ColumnOverride columnOverride = tc.getColumnOverride(cd
+ Map<ActualTableName, List<IntrospectedColumn>> columns) {
+ for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
+ for (IntrospectedColumn introspectedColumn : entry.getValue()) {
+ ColumnOverride columnOverride = tc.getColumnOverride(introspectedColumn
.getActualColumnName());
if (columnOverride != null) {
if (StringUtility.stringHasValue(columnOverride.getJavaProperty())) {
- cd.setJavaProperty(columnOverride.getJavaProperty());
+ introspectedColumn.setJavaProperty(columnOverride.getJavaProperty());
}
if (StringUtility.stringHasValue(columnOverride.getJavaType())) {
- cd.getResolvedJavaType()
- .setFullyQualifiedJavaType(
+ introspectedColumn.
+ setFullyQualifiedJavaType(
new FullyQualifiedJavaType(columnOverride
.getJavaType()));
}
if (StringUtility.stringHasValue(columnOverride.getJdbcType())) {
- cd.getResolvedJavaType().setJdbcTypeName(
+ introspectedColumn.setJdbcTypeName(
columnOverride.getJdbcType());
}
if (StringUtility.stringHasValue(columnOverride.getTypeHandler())) {
- cd.setTypeHandler(columnOverride.getTypeHandler());
+ introspectedColumn.setTypeHandler(columnOverride.getTypeHandler());
}
if (columnOverride.isColumnNameDelimited()) {
- cd.setColumnNameDelimited(true);
+ introspectedColumn.setColumnNameDelimited(true);
}
}
}
@@ -325,7 +327,7 @@
* @return introspected columns
* @throws SQLException
*/
- private Map<ActualTableName, List<ColumnDefinition>> getColumns(TableConfiguration tc) throws SQLException {
+ private Map<ActualTableName, List<IntrospectedColumn>> getColumns(TableConfiguration tc) throws SQLException {
String localCatalog;
String localSchema;
String localTableName;
@@ -390,32 +392,32 @@
localTableName = sb.toString();
}
- Map<ActualTableName, List<ColumnDefinition>> answer = new HashMap<ActualTableName, List<ColumnDefinition>>();
+ Map<ActualTableName, List<IntrospectedColumn>> answer = new HashMap<ActualTableName, List<IntrospectedColumn>>();
ResultSet rs = databaseMetaData.getColumns(localCatalog, localSchema,
localTableName, null);
while (rs.next()) {
- ColumnDefinition cd = new ColumnDefinition(tc.getAlias(), ibatorContext);
+ // TODO - needs to be configurable
+ IntrospectedColumn introspectedColumn = new IntrospectedColumn(tc.getAlias(), ibatorContext);
- cd.setJdbcType(rs.getInt("DATA_TYPE")); //$NON-NLS-1$
- cd.setLength(rs.getInt("COLUMN_SIZE")); //$NON-NLS-1$
- cd.setActualColumnName(rs.getString("COLUMN_NAME")); //$NON-NLS-1$
- cd.setNullable(rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable); //$NON-NLS-1$
- cd.setScale(rs.getInt("DECIMAL_DIGITS")); //$NON-NLS-1$
- cd.setTypeName(rs.getString("TYPE_NAME")); //$NON-NLS-1$
+ introspectedColumn.setJdbcType(rs.getInt("DATA_TYPE")); //$NON-NLS-1$
+ introspectedColumn.setLength(rs.getInt("COLUMN_SIZE")); //$NON-NLS-1$
+ introspectedColumn.setActualColumnName(rs.getString("COLUMN_NAME")); //$NON-NLS-1$
+ introspectedColumn.setNullable(rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable); //$NON-NLS-1$
+ introspectedColumn.setScale(rs.getInt("DECIMAL_DIGITS")); //$NON-NLS-1$
ActualTableName atn = new ActualTableName(rs.getString("TABLE_CAT"), //$NON-NLS-1$
rs.getString("TABLE_SCHEM"), //$NON-NLS-1$
rs.getString("TABLE_NAME")); //$NON-NLS-1$
- List<ColumnDefinition> columns = answer.get(atn);
+ List<IntrospectedColumn> columns = answer.get(atn);
if (columns == null) {
- columns = new ArrayList<ColumnDefinition>();
+ columns = new ArrayList<IntrospectedColumn>();
answer.put(atn, columns);
}
- columns.add(cd);
+ columns.add(introspectedColumn);
}
closeResultSet(rs);
@@ -424,7 +426,7 @@
}
private List<IntrospectedTable> calculateIntrospectedTables(TableConfiguration tc,
- Map<ActualTableName, List<ColumnDefinition>> columns) {
+ Map<ActualTableName, List<IntrospectedColumn>> columns) {
boolean delimitIdentifiers = tc.isDelimitIdentifiers()
|| StringUtility.stringContainsSpace(tc.getCatalog())
|| StringUtility.stringContainsSpace(tc.getSchema())
@@ -432,7 +434,7 @@
List<IntrospectedTable> answer = new ArrayList<IntrospectedTable>();
- for (Map.Entry<ActualTableName, List<ColumnDefinition>> entry : columns.entrySet()) {
+ for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns.entrySet()) {
ActualTableName atn = entry.getKey();
// we only use the returned catalog and schema if something was actually
@@ -453,16 +455,15 @@
delimitIdentifiers,
ibatorContext);
- ColumnDefinitions cds = new ColumnDefinitions();
+ IntrospectedTable introspectedTable =
+ IbatorObjectFactory.createIntrospectedTable(tc, table, ibatorContext);
- for (ColumnDefinition cd : entry.getValue()) {
- cds.addColumn(cd);
+ for (IntrospectedColumn introspectedColumn : entry.getValue()) {
+ introspectedTable.addColumn(introspectedColumn);
}
- calculatePrimaryKey(table, cds);
+ calculatePrimaryKey(table, introspectedTable);
- IntrospectedTable introspectedTable =
- IbatorObjectFactory.createIntrospectedTable(tc, cds, table, ibatorContext);
answer.add(introspectedTable);
}
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=703569&r1=703568&r2=703569&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 Fri Oct 10 13:08:10 2008
@@ -21,11 +21,11 @@
import java.util.List;
import java.util.Properties;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
import org.apache.ibatis.ibator.api.JavaTypeResolver;
import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
import org.apache.ibatis.ibator.config.IbatorContext;
import org.apache.ibatis.ibator.config.PropertyRegistry;
-import org.apache.ibatis.ibator.internal.db.ColumnDefinition;
import org.apache.ibatis.ibator.internal.util.StringUtility;
/**
@@ -53,190 +53,154 @@
* (non-Javadoc)
* @see org.apache.ibatis.ibator.api.JavaTypeResolver#initializeResolvedJavaType(org.apache.ibatis.ibator.internal.db.ColumnDefinition)
*/
- public boolean initializeResolvedJavaType(ColumnDefinition cd) {
+ public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
boolean forceBigDecimals = StringUtility.isTrue(properties
.getProperty(PropertyRegistry.TYPE_RESOLVER_FORCE_BIG_DECIMALS));
- boolean rc = true;
- ResolvedJavaType type = new ResolvedJavaType();
-
- switch (cd.getJdbcType()) {
+ FullyQualifiedJavaType answer;
+ switch (introspectedColumn.getJdbcType()) {
case Types.ARRAY:
- type.setJdbcTypeName("ARRAY"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.BIGINT:
- type.setJdbcTypeName("BIGINT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Long.class.getName()));
+ answer = new FullyQualifiedJavaType(Long.class.getName());
break;
case Types.BINARY:
- type.setJdbcTypeName("BINARY"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
break;
case Types.BIT:
- type.setJdbcTypeName("BIT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Boolean.class.getName()));
+ answer = new FullyQualifiedJavaType(Boolean.class.getName());
break;
case Types.BLOB:
- type.setJdbcTypeName("BLOB"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
break;
case Types.BOOLEAN:
- type.setJdbcTypeName("BOOLEAN"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Boolean.class.getName()));
+ answer = new FullyQualifiedJavaType(Boolean.class.getName());
break;
case Types.CHAR:
- type.setJdbcTypeName("CHAR"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(String.class.getName()));
+ answer = new FullyQualifiedJavaType(String.class.getName());
break;
case Types.CLOB:
- type.setJdbcTypeName("CLOB"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(String.class.getName()));
+ answer = new FullyQualifiedJavaType(String.class.getName());
break;
case Types.DATALINK:
- type.setJdbcTypeName("DATALINK"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.DATE:
- type.setJdbcTypeName("DATE"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Date.class.getName()));
+ answer = new FullyQualifiedJavaType(Date.class.getName());
break;
case Types.DECIMAL:
- type.setJdbcTypeName("DECIMAL"); //$NON-NLS-1$
- if (cd.getScale() > 0 || cd.getLength() > 18 || forceBigDecimals) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(BigDecimal.class.getName()));
- } else if (cd.getLength() > 9) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Long.class.getName()));
- } else if (cd.getLength() > 4) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Integer.class.getName()));
+ 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) {
+ answer = new FullyQualifiedJavaType(Integer.class.getName());
} else {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Short.class.getName()));
+ answer = new FullyQualifiedJavaType(Short.class.getName());
}
break;
case Types.DISTINCT:
- type.setJdbcTypeName("DISTINCT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.DOUBLE:
- type.setJdbcTypeName("DOUBLE"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Double.class.getName()));
+ answer = new FullyQualifiedJavaType(Double.class.getName());
break;
case Types.FLOAT:
- type.setJdbcTypeName("FLOAT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Double.class.getName()));
+ answer = new FullyQualifiedJavaType(Double.class.getName());
break;
case Types.INTEGER:
- type.setJdbcTypeName("INTEGER"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Integer.class.getName()));
+ answer = new FullyQualifiedJavaType(Integer.class.getName());
break;
case Types.JAVA_OBJECT:
- type.setJdbcTypeName("JAVA_OBJECT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.LONGVARBINARY:
- type.setJdbcTypeName("LONGVARBINARY"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
break;
case Types.LONGVARCHAR:
- type.setJdbcTypeName("LONGVARCHAR"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(String.class.getName()));
+ answer = new FullyQualifiedJavaType(String.class.getName());
break;
case Types.NULL:
- type.setJdbcTypeName("NULL"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.NUMERIC:
- type.setJdbcTypeName("NUMERIC"); //$NON-NLS-1$
- if (cd.getScale() > 0 || cd.getLength() > 18 || forceBigDecimals) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(BigDecimal.class.getName()));
- } else if (cd.getLength() > 9) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Long.class.getName()));
- } else if (cd.getLength() > 4) {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Integer.class.getName()));
+ 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) {
+ answer = new FullyQualifiedJavaType(Integer.class.getName());
} else {
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Short.class.getName()));
+ answer = new FullyQualifiedJavaType(Short.class.getName());
}
break;
case Types.OTHER:
- type.setJdbcTypeName("OTHER"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.REAL:
- type.setJdbcTypeName("REAL"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Float.class.getName()));
+ answer = new FullyQualifiedJavaType(Float.class.getName());
break;
case Types.REF:
- type.setJdbcTypeName("REF"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.SMALLINT:
- type.setJdbcTypeName("SMALLINT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Short.class.getName()));
+ answer = new FullyQualifiedJavaType(Short.class.getName());
break;
case Types.STRUCT:
- type.setJdbcTypeName("STRUCT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Object.class.getName()));
+ answer = new FullyQualifiedJavaType(Object.class.getName());
break;
case Types.TIME:
- type.setJdbcTypeName("TIME"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Date.class.getName()));
+ answer = new FullyQualifiedJavaType(Date.class.getName());
break;
case Types.TIMESTAMP:
- type.setJdbcTypeName("TIMESTAMP"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Date.class.getName()));
+ answer = new FullyQualifiedJavaType(Date.class.getName());
break;
case Types.TINYINT:
- type.setJdbcTypeName("TINYINT"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(Byte.class.getName()));
+ answer = new FullyQualifiedJavaType(Byte.class.getName());
break;
case Types.VARBINARY:
- type.setJdbcTypeName("VARBINARY"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType("byte[]")); //$NON-NLS-1$
+ answer = new FullyQualifiedJavaType("byte[]"); //$NON-NLS-1$
break;
case Types.VARCHAR:
- type.setJdbcTypeName("VARCHAR"); //$NON-NLS-1$
- type.setFullyQualifiedJavaType(new FullyQualifiedJavaType(String.class.getName()));
+ answer = new FullyQualifiedJavaType(String.class.getName());
break;
default:
- rc = false;
+ answer = null;
break;
}
- if (rc) {
- cd.setResolvedJavaType(type);
- }
-
- return rc;
+ return answer;
}
/* (non-Javadoc)
Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/types/JdbcTypeNameTranslator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2008 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ibatis.ibator.internal.types;
+
+import java.sql.Types;
+
+/**
+ *
+ * @author Jeff Butler
+ */
+public class JdbcTypeNameTranslator {
+
+ /**
+ * Utility Class - no instances
+ */
+ private JdbcTypeNameTranslator() {
+ super();
+ }
+
+ /**
+ *
+ * @param jdbcType a value from java.sql.Types
+ * @return
+ */
+ public static String getJdbcTypeName(int jdbcType) {
+ String answer;
+
+ switch (jdbcType) {
+ case Types.ARRAY:
+ answer = "ARRAY"; //$NON-NLS-1$
+ break;
+
+ case Types.BIGINT:
+ answer = "BIGINT"; //$NON-NLS-1$
+ break;
+
+ case Types.BINARY:
+ answer = "BINARY"; //$NON-NLS-1$
+ break;
+
+ case Types.BIT:
+ answer = "BIT"; //$NON-NLS-1$
+ break;
+
+ case Types.BLOB:
+ answer = "BLOB"; //$NON-NLS-1$
+ break;
+
+ case Types.BOOLEAN:
+ answer = "BOOLEAN"; //$NON-NLS-1$
+ break;
+
+ case Types.CHAR:
+ answer = "CHAR"; //$NON-NLS-1$
+ break;
+
+ case Types.CLOB:
+ answer = "CLOB"; //$NON-NLS-1$
+ break;
+
+ case Types.DATALINK:
+ answer = "DATALINK"; //$NON-NLS-1$
+ break;
+
+ case Types.DATE:
+ answer = "DATE"; //$NON-NLS-1$
+ break;
+
+ case Types.DECIMAL:
+ answer = "DECIMAL"; //$NON-NLS-1$
+ break;
+
+ case Types.DISTINCT:
+ answer = "DISTINCT"; //$NON-NLS-1$
+ break;
+
+ case Types.DOUBLE:
+ answer = "DOUBLE"; //$NON-NLS-1$
+ break;
+
+ case Types.FLOAT:
+ answer = "FLOAT"; //$NON-NLS-1$
+ break;
+
+ case Types.INTEGER:
+ answer = "INTEGER"; //$NON-NLS-1$
+ break;
+
+ case Types.JAVA_OBJECT:
+ answer = "JAVA_OBJECT"; //$NON-NLS-1$
+ break;
+
+ case Types.LONGVARBINARY:
+ answer = "LONGVARBINARY"; //$NON-NLS-1$
+ break;
+
+ case Types.LONGVARCHAR:
+ answer = "LONGVARCHAR"; //$NON-NLS-1$
+ break;
+
+ case Types.NULL:
+ answer = "NULL"; //$NON-NLS-1$
+ break;
+
+ case Types.NUMERIC:
+ answer = "NUMERIC"; //$NON-NLS-1$
+ break;
+
+ case Types.OTHER:
+ answer = "OTHER"; //$NON-NLS-1$
+ break;
+
+ case Types.REAL:
+ answer = "REAL"; //$NON-NLS-1$
+ break;
+
+ case Types.REF:
+ answer = "REF"; //$NON-NLS-1$
+ break;
+
+ case Types.SMALLINT:
+ answer = "SMALLINT"; //$NON-NLS-1$
+ break;
+
+ case Types.STRUCT:
+ answer = "STRUCT"; //$NON-NLS-1$
+ break;
+
+ case Types.TIME:
+ answer = "TIME"; //$NON-NLS-1$
+ break;
+
+ case Types.TIMESTAMP:
+ answer = "TIMESTAMP"; //$NON-NLS-1$
+ break;
+
+ case Types.TINYINT:
+ answer = "TINYINT"; //$NON-NLS-1$
+ break;
+
+ case Types.VARBINARY:
+ answer = "VARBINARY"; //$NON-NLS-1$
+ break;
+
+ case Types.VARCHAR:
+ answer = "VARCHAR"; //$NON-NLS-1$
+ break;
+
+ default:
+ answer = "OTHER"; //$NON-NLS-1$
+ break;
+ }
+
+ return answer;
+ }
+}
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/internal/util/messages/messages.properties Fri Oct 10 13:08:10 2008
@@ -49,7 +49,7 @@
Warning.9=The specified target project directory {0} does not exist
Warning.10=Cannot create directory {0}
Warning.11=Existing file {0} was overwritten
-Warning.12=The exisiting XML file {0} is not the same format as the generated file. \
+Warning.12=The existing XML file {0} is not the same format as the generated file. \
The existing file will not be changed.
Warning.13=Exception while attempting to merge the XML file {0}. \
The existing file will not be changed.
Modified: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/EqualsHashCodePlugin.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/EqualsHashCodePlugin.java?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/EqualsHashCodePlugin.java (original)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/plugins/EqualsHashCodePlugin.java Fri Oct 10 13:08:10 2008
@@ -19,6 +19,7 @@
import java.util.List;
import org.apache.ibatis.ibator.api.IbatorPluginAdapter;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
import org.apache.ibatis.ibator.api.IntrospectedTable;
import org.apache.ibatis.ibator.api.dom.OutputUtilities;
import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
@@ -27,7 +28,6 @@
import org.apache.ibatis.ibator.api.dom.java.Parameter;
import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
import org.apache.ibatis.ibator.config.IbatorContext;
-import org.apache.ibatis.ibator.internal.db.ColumnDefinition;
import org.apache.ibatis.ibator.internal.util.JavaBeansUtil;
/**
@@ -64,13 +64,13 @@
public void setIbatorContext(IbatorContext ibatorContext) {
super.setIbatorContext(ibatorContext);
usingJava5 = "Java5".equalsIgnoreCase(ibatorContext //$NON-NLS-1$
- .getConfiguredGeneratorSet());
+ .getTargetJRE());
}
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
- List<ColumnDefinition> columns;
+ List<IntrospectedColumn> columns;
if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
columns = introspectedTable.getNonBLOBColumns();
} else {
@@ -121,7 +121,7 @@
* @param introspectedTable the table corresponding to this class
*/
protected void generateEquals(TopLevelClass topLevelClass,
- List<ColumnDefinition> columnDefinitions,
+ List<IntrospectedColumn> introspectedColumns,
IntrospectedTable introspectedTable) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
@@ -157,9 +157,9 @@
method.addBodyLine(sb.toString());
boolean first = true;
- Iterator<ColumnDefinition> iter = columnDefinitions.iterator();
+ Iterator<IntrospectedColumn> iter = introspectedColumns.iterator();
while (iter.hasNext()) {
- ColumnDefinition columnDefinition = iter.next();
+ IntrospectedColumn introspectedColumn = iter.next();
sb.setLength(0);
@@ -172,10 +172,10 @@
}
String getterMethod = JavaBeansUtil.getGetterMethodName(
- columnDefinition.getJavaProperty(), columnDefinition
- .getResolvedJavaType().getFullyQualifiedJavaType());
+ introspectedColumn.getJavaProperty(), introspectedColumn
+ .getFullyQualifiedJavaType());
- if (columnDefinition.getResolvedJavaType()
+ if (introspectedColumn
.getFullyQualifiedJavaType().isPrimitive()) {
sb.append("this."); //$NON-NLS-1$
sb.append(getterMethod);
@@ -215,7 +215,7 @@
* @param introspectedTable the table corresponding to this class
*/
protected void generateHashCode(TopLevelClass topLevelClass,
- List<ColumnDefinition> columnDefinitions,
+ List<IntrospectedColumn> introspectedColumns,
IntrospectedTable introspectedTable) {
Method method = new Method();
method.setVisibility(JavaVisibility.PUBLIC);
@@ -234,16 +234,16 @@
StringBuilder sb = new StringBuilder();
boolean valueDeclared = false;
- Iterator<ColumnDefinition> iter = columnDefinitions.iterator();
+ Iterator<IntrospectedColumn> iter = introspectedColumns.iterator();
while (iter.hasNext()) {
- ColumnDefinition columnDefinition = iter.next();
+ IntrospectedColumn introspectedColumn = iter.next();
- FullyQualifiedJavaType fqjt = columnDefinition.getResolvedJavaType()
+ FullyQualifiedJavaType fqjt = introspectedColumn
.getFullyQualifiedJavaType();
String getterMethod = JavaBeansUtil.getGetterMethodName(
- columnDefinition.getJavaProperty(), fqjt);
+ introspectedColumn.getJavaProperty(), fqjt);
if (fqjt.isPrimitive()) {
boolean cast = false;
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=703569&r1=703568&r2=703569&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 Fri Oct 10 13:08:10 2008
@@ -26,7 +26,7 @@
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.internal.sqlmap.XmlConstants;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
import org.apache.ibatis.ibator.internal.util.StringUtility;
import org.apache.ibatis.ibator.internal.util.messages.Messages;
Modified: ibatis/trunk/java/tools/ibator/core/testJava2/ibatortest/java2/ibatorConfig.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/testJava2/ibatortest/java2/ibatorConfig.xml?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/testJava2/ibatortest/java2/ibatorConfig.xml (original)
+++ ibatis/trunk/java/tools/ibator/core/testJava2/ibatortest/java2/ibatorConfig.xml Fri Oct 10 13:08:10 2008
@@ -5,7 +5,7 @@
<ibatorConfiguration>
- <ibatorContext id="FlatJava2" generatorSet="Java2" defaultModelType="flat">
+ <ibatorContext id="FlatJava2" targetJRE="Java2" defaultModelType="flat">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.SqlMapConfigPlugin" >
<property name="targetPackage" value="ibatortest.java2.generated.flat" />
@@ -49,7 +49,7 @@
</table>
</ibatorContext>
- <ibatorContext id="HierarchicalJava2" generatorSet="Java2" defaultModelType="hierarchical">
+ <ibatorContext id="HierarchicalJava2" targetJRE="Java2" defaultModelType="hierarchical">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
@@ -89,7 +89,7 @@
</table>
</ibatorContext>
- <ibatorContext id="ConditionalJava2" generatorSet="Java2" defaultModelType="conditional">
+ <ibatorContext id="ConditionalJava2" targetJRE="Java2" defaultModelType="conditional">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
@@ -129,7 +129,7 @@
</table>
</ibatorContext>
- <ibatorContext id="miscellaneousTests" generatorSet="Java2">
+ <ibatorContext id="miscellaneousTests" targetJRE="Java2">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
Modified: ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml?rev=703569&r1=703568&r2=703569&view=diff
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml (original)
+++ ibatis/trunk/java/tools/ibator/core/testJava5/ibatortest/ibatorConfig.xml Fri Oct 10 13:08:10 2008
@@ -6,7 +6,7 @@
<ibatorConfiguration>
<classPathEntry location="${generated.bin.dir.java5}"/>
- <ibatorContext id="FlatJava5" generatorSet="Java5" defaultModelType="flat">
+ <ibatorContext id="FlatJava5" targetJRE="Java5" defaultModelType="flat">
<property name="suppressTypeWarnings" value="true" /> <!-- should be ignored -->
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
@@ -52,7 +52,7 @@
</table>
</ibatorContext>
- <ibatorContext id="FlatJava2" generatorSet="Java2" defaultModelType="flat">
+ <ibatorContext id="FlatJava2" targetJRE="Java2" defaultModelType="flat">
<property name="suppressTypeWarnings" value="true" />
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
@@ -94,7 +94,7 @@
</table>
</ibatorContext>
- <ibatorContext id="HierarchicalJava5" generatorSet="Java5" defaultModelType="hierarchical">
+ <ibatorContext id="HierarchicalJava5" targetJRE="Java5" defaultModelType="hierarchical">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<jdbcConnection driverClass="org.hsqldb.jdbcDriver"
@@ -134,7 +134,7 @@
</table>
</ibatorContext>
- <ibatorContext id="HierarchicalJava2" generatorSet="Java2" defaultModelType="hierarchical">
+ <ibatorContext id="HierarchicalJava2" targetJRE="Java2" defaultModelType="hierarchical">
<property name="suppressTypeWarnings" value="true" />
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
@@ -176,7 +176,7 @@
</table>
</ibatorContext>
- <ibatorContext id="ConditionalJava5" generatorSet="Java5" defaultModelType="conditional">
+ <ibatorContext id="ConditionalJava5" targetJRE="Java5" defaultModelType="conditional">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.SerializablePlugin" />
@@ -217,7 +217,7 @@
</table>
</ibatorContext>
- <ibatorContext id="ConditionalJava2" generatorSet="Java2" defaultModelType="conditional">
+ <ibatorContext id="ConditionalJava2" targetJRE="Java2" defaultModelType="conditional">
<property name="suppressTypeWarnings" value="true" />
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
@@ -259,7 +259,7 @@
</table>
</ibatorContext>
- <ibatorContext id="miscellaneousTests" generatorSet="Java5">
+ <ibatorContext id="miscellaneousTests" targetJRE="Java5">
<ibatorPlugin type="org.apache.ibatis.ibator.plugins.EqualsHashCodePlugin" />
<commentGenerator>