ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgbut...@apache.org
Subject svn commit: r703569 [5/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...
Date Fri, 10 Oct 2008 20:08:12 GMT
Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RecordWithBLOBsGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RecordWithBLOBsGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RecordWithBLOBsGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RecordWithBLOBsGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,98 @@
+/*
+ *  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.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ibatis.ibator.api.CommentGenerator;
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.IbatorPlugin;
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.api.dom.java.CompilationUnit;
+import org.apache.ibatis.ibator.api.dom.java.Field;
+import org.apache.ibatis.ibator.api.dom.java.FullyQualifiedJavaType;
+import org.apache.ibatis.ibator.api.dom.java.JavaVisibility;
+import org.apache.ibatis.ibator.api.dom.java.Method;
+import org.apache.ibatis.ibator.api.dom.java.TopLevelClass;
+import org.apache.ibatis.ibator.generator.JavaGenerator;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class RecordWithBLOBsGenerator extends BaseModelClassGenerator implements JavaGenerator {
+
+    public RecordWithBLOBsGenerator() {
+        super();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ibatis.ibator.generator.ibatis2.model.ModelGenerator#getTopLevelClass(org.apache.ibatis.ibator.api.IntrospectedTable, java.util.List)
+     */
+    public List<CompilationUnit> getCompilationUnits() {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        progressCallback.startSubTask(Messages.getString("Progress.9", table.toString()));
+        IbatorPlugin plugins = ibatorContext.getPlugins();
+        CommentGenerator commentGenerator = ibatorContext.getCommentGenerator();
+        
+        FullyQualifiedJavaType type = introspectedTable.getRecordWithBLOBsType();
+        TopLevelClass topLevelClass = new TopLevelClass(type);
+        topLevelClass.setVisibility(JavaVisibility.PUBLIC);
+        commentGenerator.addJavaFileComment(topLevelClass);
+
+        String rootClass = getRootClass();
+        if (introspectedTable.getRules().generateBaseRecordClass()) {
+            topLevelClass.setSuperClass(introspectedTable.getBaseRecordType());
+        } else {
+            topLevelClass.setSuperClass(introspectedTable.getPrimaryKeyType());
+        }
+        
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getBLOBColumns()) {
+            if (RootClassInfo.getInstance(rootClass, warnings).containsProperty(introspectedColumn)) {
+                continue;
+            }
+            
+            Field field = getJavaBeansField(introspectedColumn);
+            if (plugins.modelFieldGenerated(field, topLevelClass, introspectedColumn, introspectedTable)) {
+                topLevelClass.addField(field);
+                topLevelClass.addImportedType(field.getType());
+            }
+            
+            Method method = getJavaBeansGetter(introspectedColumn);
+            if (plugins.modelGetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable)) {
+                topLevelClass.addMethod(method);
+            }
+            
+            method = getJavaBeansSetter(introspectedColumn);
+            if (plugins.modelSetterMethodGenerated(method, topLevelClass, introspectedColumn, introspectedTable)) {
+                topLevelClass.addMethod(method);
+            }
+        }
+
+        List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
+        if (ibatorContext.getPlugins().modelRecordWithBLOBsClassGenerated(topLevelClass, introspectedTable)) {
+            answer.add(topLevelClass);
+        }
+        return answer;
+    }
+
+    public int getNumberOfSubtasks() {
+        return 1;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RootClassInfo.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RootClassInfo.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RootClassInfo.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/model/RootClassInfo.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,121 @@
+/*
+ *  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.model;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.ibator.api.IntrospectedColumn;
+import org.apache.ibatis.ibator.internal.IbatorObjectFactory;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class RootClassInfo {
+
+    private static Map<String, RootClassInfo> rootClassInfoMap;
+
+    static {
+        rootClassInfoMap = Collections.synchronizedMap(new HashMap<String, RootClassInfo>());
+    }
+    
+    public static RootClassInfo getInstance(String className, List<String> warnings) {
+        RootClassInfo classInfo = rootClassInfoMap.get(className);
+        if (classInfo == null) {
+            classInfo = new RootClassInfo(className, warnings);
+            rootClassInfoMap.put(className, classInfo);
+        }
+        
+        return classInfo;
+    }
+    
+    private PropertyDescriptor[] propertyDescriptors;
+    private String className;
+    private List<String> warnings;
+    
+    private RootClassInfo(String className, List<String> warnings) {
+        super();
+        this.className = className;
+        this.warnings = warnings;
+        
+        if (className == null) {
+            return;
+        }
+        
+        try {
+            Class<?> clazz = IbatorObjectFactory.loadClass(className);
+            BeanInfo bi = Introspector.getBeanInfo(clazz);
+            propertyDescriptors = bi.getPropertyDescriptors();
+        } catch (Exception e) {
+            propertyDescriptors = null;
+            warnings.add(Messages.getString("Warning.20", className)); //$NON-NLS-1$
+        }
+    }
+
+    public boolean containsProperty(IntrospectedColumn introspectedColumn) {
+        if (propertyDescriptors == null) {
+            return false;
+        }
+        
+        boolean found = false;
+        String propertyName = introspectedColumn.getJavaProperty();
+        String propertyType = introspectedColumn.getFullyQualifiedJavaType().getFullyQualifiedName();
+        
+        // get method names from class and check against this column definition.
+        // better yet, have a map of method Names. check against it.
+        for (int i = 0; i < propertyDescriptors.length; i++) {
+            PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+            
+            if (propertyDescriptor.getName().equals(propertyName)) {
+                // property is in the rootClass...
+
+                // Is it the proper type?
+                if (!propertyDescriptor.getPropertyType().getName().equals(propertyType)) {
+                    warnings.add(Messages.getString("Warning.21", //$NON-NLS-1$
+                            propertyName, className, propertyType));
+                    break;
+                }
+                
+                // Does it have a getter?
+                if (propertyDescriptor.getReadMethod() == null) {
+                    warnings.add(Messages.getString("Warning.22", //$NON-NLS-1$
+                            propertyName, className));
+                    break;
+                }
+                
+                // Does it have a setter?
+                if (propertyDescriptor.getWriteMethod() == null) {
+                    warnings.add(Messages.getString("Warning.23", //$NON-NLS-1$
+                            propertyName, className));
+                    break;
+                }
+                
+                found = true;
+                break;
+            }
+        }
+
+        return found;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/SqlMapGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/SqlMapGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/SqlMapGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/SqlMapGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,228 @@
+/*
+ *  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;
+
+import org.apache.ibatis.ibator.api.FullyQualifiedTable;
+import org.apache.ibatis.ibator.api.dom.xml.Attribute;
+import org.apache.ibatis.ibator.api.dom.xml.Document;
+import org.apache.ibatis.ibator.api.dom.xml.XmlElement;
+import org.apache.ibatis.ibator.generator.AbstractGeneratorImpl;
+import org.apache.ibatis.ibator.generator.XmlGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.CountByExampleElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.DeleteByExampleElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.DeleteByPrimaryKeyElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.ExampleWhereClauseElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.InsertElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.InsertSelectiveElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.ResultMapWithBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.ResultMapWithoutBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.SelectByExampleWithBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.SelectByExampleWithoutBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.SelectByPrimaryKeyElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByExampleSelectiveElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByExampleWithBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByExampleWithoutBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByPrimaryKeySelectiveElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByPrimaryKeyWithBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.UpdateByPrimaryKeyWithoutBLOBsElementGenerator;
+import org.apache.ibatis.ibator.generator.ibatis2.sqlmap.elements.XmlElementGenerator;
+import org.apache.ibatis.ibator.internal.util.messages.Messages;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class SqlMapGenerator extends AbstractGeneratorImpl implements XmlGenerator {
+
+    public SqlMapGenerator() {
+        super();
+    }
+
+    protected XmlElement getSqlMapElement() {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        progressCallback.startSubTask(Messages.getString("Progress.12", table.toString()));
+        XmlElement answer = new XmlElement("sqlMap"); //$NON-NLS-1$
+        answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
+                table.getSqlMapNamespace()));
+
+        ibatorContext.getCommentGenerator().addRootComment(answer);
+        
+        addResultMapWithoutBLOBsElement(answer);
+        addResultMapWithBLOBsElement(answer);
+        addExampleWhereClauseElement(answer);
+        addSelectByExampleWithBLOBsElement(answer);
+        addSelectByExampleWithoutBLOBsElement(answer);
+        addSelectByPrimaryKeyElement(answer);
+        addDeleteByPrimaryKeyElement(answer);
+        addDeleteByExampleElement(answer);
+        addInsertElement(answer);
+        addInsertSelectiveElement(answer);
+        addCountByExampleElement(answer);
+        addUpdateByExampleSelectiveElement(answer);
+        addUpdateByExampleWithBLOBsElement(answer);
+        addUpdateByExampleWithoutBLOBsElement(answer);
+        addUpdateByPrimaryKeySelectiveElement(answer);
+        addUpdateByPrimaryKeyWithBLOBsElement(answer);
+        addUpdateByPrimaryKeyWithoutBLOBsElement(answer);
+
+        return answer;
+    }
+    
+    protected void addResultMapWithoutBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateBaseResultMap()) {
+            XmlElementGenerator elementGenerator = new ResultMapWithoutBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+    
+    protected void addResultMapWithBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateResultMapWithBLOBs()) {
+            XmlElementGenerator elementGenerator = new ResultMapWithBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+    
+    protected void addExampleWhereClauseElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateSQLExampleWhereClause()) {
+            XmlElementGenerator elementGenerator = new ExampleWhereClauseElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+    
+    protected void addSelectByExampleWithoutBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateSelectByExampleWithoutBLOBs()) {
+            XmlElementGenerator elementGenerator = new SelectByExampleWithoutBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+    
+    protected void addSelectByExampleWithBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateSelectByExampleWithBLOBs()) {
+            XmlElementGenerator elementGenerator = new SelectByExampleWithBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addSelectByPrimaryKeyElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateSelectByPrimaryKey()) {
+            XmlElementGenerator elementGenerator = new SelectByPrimaryKeyElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addDeleteByExampleElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateDeleteByExample()) {
+            XmlElementGenerator elementGenerator = new DeleteByExampleElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addDeleteByPrimaryKeyElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateDeleteByPrimaryKey()) {
+            XmlElementGenerator elementGenerator = new DeleteByPrimaryKeyElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addInsertElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateInsert()) {
+            XmlElementGenerator elementGenerator = new InsertElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addInsertSelectiveElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateInsertSelective()) {
+            XmlElementGenerator elementGenerator = new InsertSelectiveElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addCountByExampleElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateCountByExample()) {
+            XmlElementGenerator elementGenerator = new CountByExampleElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByExampleSelectiveElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByExampleSelective()) {
+            XmlElementGenerator elementGenerator = new UpdateByExampleSelectiveElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByExampleWithBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByExampleWithBLOBs()) {
+            XmlElementGenerator elementGenerator = new UpdateByExampleWithBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByExampleWithoutBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByExampleWithoutBLOBs()) {
+            XmlElementGenerator elementGenerator = new UpdateByExampleWithoutBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByPrimaryKeySelectiveElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeySelective()) {
+            XmlElementGenerator elementGenerator = new UpdateByPrimaryKeySelectiveElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByPrimaryKeyWithBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithBLOBs()) {
+            XmlElementGenerator elementGenerator = new UpdateByPrimaryKeyWithBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+
+    protected void addUpdateByPrimaryKeyWithoutBLOBsElement(XmlElement parentElement) {
+        if (introspectedTable.getRules().generateUpdateByPrimaryKeyWithoutBLOBs()) {
+            XmlElementGenerator elementGenerator = new UpdateByPrimaryKeyWithoutBLOBsElementGenerator();
+            initializeAndExecuteGenerator(elementGenerator, parentElement);
+        }
+    }
+    
+    protected void initializeAndExecuteGenerator(XmlElementGenerator elementGenerator, XmlElement parentElement) {
+        elementGenerator.setIbatorContext(ibatorContext);
+        elementGenerator.setIntrospectedTable(introspectedTable);
+        elementGenerator.setProgressCallback(progressCallback);
+        elementGenerator.setWarnings(warnings);
+        elementGenerator.addElements(parentElement);
+    }
+
+    public Document getDocument() {
+        Document document = new Document(XmlConstants.SQL_MAP_PUBLIC_ID,
+                XmlConstants.SQL_MAP_SYSTEM_ID);
+        document.setRootElement(getSqlMapElement());
+
+        if (!ibatorContext.getPlugins().sqlMapDocumentGenerated(document, introspectedTable)) {
+            document = null;
+        }
+        
+        return document;
+    }
+
+    public int getNumberOfSubtasks() {
+        return 1;
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/CountByExampleElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/CountByExampleElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/CountByExampleElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/CountByExampleElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,71 @@
+/*
+ *  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.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 CountByExampleElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public CountByExampleElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        FullyQualifiedJavaType fqjt = introspectedTable.getExampleType();
+
+        answer
+                .addAttribute(new Attribute(
+                        "id", XmlConstants.COUNT_BY_EXAMPLE_STATEMENT_ID)); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "parameterClass", fqjt.getFullyQualifiedName())); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "resultClass", "java.lang.Integer")); //$NON-NLS-1$ //$NON-NLS-2$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("select count(*) from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        sb.setLength(0);
+        sb.append(table.getSqlMapNamespace());
+        sb.append('.');
+        sb.append(XmlConstants.EXAMPLE_WHERE_CLAUSE_ID);
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                sb.toString()));
+
+        answer.addElement(includeElement);
+
+        if (ibatorContext.getPlugins().sqlMapCountByExampleElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByExampleElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByExampleElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByExampleElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByExampleElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,69 @@
+/*
+ *  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.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 DeleteByExampleElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public DeleteByExampleElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        FullyQualifiedJavaType fqjt = introspectedTable.getExampleType();
+
+        answer
+                .addAttribute(new Attribute(
+                        "id", XmlConstants.DELETE_BY_EXAMPLE_STATEMENT_ID)); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "parameterClass", fqjt.getFullyQualifiedName())); //$NON-NLS-1$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("delete from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
+        sb.setLength(0);
+        sb.append(table.getSqlMapNamespace());
+        sb.append('.');
+        sb.append(XmlConstants.EXAMPLE_WHERE_CLAUSE_ID);
+        includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
+                sb.toString()));
+
+        answer.addElement(includeElement);
+
+        if (ibatorContext.getPlugins().sqlMapDeleteByExampleElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByPrimaryKeyElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByPrimaryKeyElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByPrimaryKeyElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/DeleteByPrimaryKeyElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,79 @@
+/*
+ *  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 DeleteByPrimaryKeyElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public DeleteByPrimaryKeyElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("delete"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+        answer.addAttribute(new Attribute(
+                "id", XmlConstants.DELETE_BY_PRIMARY_KEY_STATEMENT_ID)); //$NON-NLS-1$
+        FullyQualifiedJavaType parameterClass;
+        if (introspectedTable.getRules().generatePrimaryKeyClass()) {
+            parameterClass = introspectedTable.getPrimaryKeyType();
+        } else {
+            parameterClass = introspectedTable.getBaseRecordType();
+        }
+        answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+                parameterClass.getFullyQualifiedName()));
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("delete from "); //$NON-NLS-1$
+        sb.append(table.getFullyQualifiedTableNameAtRuntime());
+        answer.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().sqlMapDeleteByPrimaryKeyElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ExampleWhereClauseElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ExampleWhereClauseElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ExampleWhereClauseElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ExampleWhereClauseElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,228 @@
+/*
+ *  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.generator.ibatis2.XmlConstants;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class ExampleWhereClauseElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public ExampleWhereClauseElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("sql"); //$NON-NLS-1$
+
+        answer.addAttribute(new Attribute("id", XmlConstants.EXAMPLE_WHERE_CLAUSE_ID)); //$NON-NLS-1$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        XmlElement outerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        outerIterateElement.addAttribute(new Attribute(
+                "property", "oredCriteria")); //$NON-NLS-1$ //$NON-NLS-2$
+        outerIterateElement.addAttribute(new Attribute("conjunction", "or")); //$NON-NLS-1$ //$NON-NLS-2$
+        outerIterateElement.addAttribute(new Attribute("prepend", "where")); //$NON-NLS-1$ //$NON-NLS-2$
+        outerIterateElement.addAttribute(new Attribute("removeFirstPrepend", "iterate")); //$NON-NLS-1$ //$NON-NLS-2$
+        answer.addElement(outerIterateElement);
+        
+        XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
+        isEqualElement.addAttribute(new Attribute("property", "oredCriteria[].valid")); //$NON-NLS-1$ //$NON-NLS-2$
+        isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
+        outerIterateElement.addElement(isEqualElement);
+
+        isEqualElement.addElement(new TextElement("(")); //$NON-NLS-1$
+
+        XmlElement innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute(
+                "property", "oredCriteria[].criteriaWithoutValue")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addElement(new TextElement(
+                "$oredCriteria[].criteriaWithoutValue[]$")); //$NON-NLS-1$
+        isEqualElement.addElement(innerIterateElement);
+
+        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute(
+                "property", "oredCriteria[].criteriaWithSingleValue")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement
+                .addElement(new TextElement(
+                        "$oredCriteria[].criteriaWithSingleValue[].condition$ #oredCriteria[].criteriaWithSingleValue[].value#")); //$NON-NLS-1$
+        isEqualElement.addElement(innerIterateElement);
+
+        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute(
+                "property", "oredCriteria[].criteriaWithListValue")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addElement(new TextElement(
+                "$oredCriteria[].criteriaWithListValue[].condition$")); //$NON-NLS-1$
+        XmlElement innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
+                "oredCriteria[].criteriaWithListValue[].values")); //$NON-NLS-1$
+        innerInnerIterateElement.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerInnerIterateElement.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerInnerIterateElement
+                .addAttribute(new Attribute("conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerInnerIterateElement.addElement(new TextElement(
+                "#oredCriteria[].criteriaWithListValue[].values[]#")); //$NON-NLS-1$
+        innerIterateElement.addElement(innerInnerIterateElement);
+        isEqualElement.addElement(innerIterateElement);
+
+        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute(
+                "property", "oredCriteria[].criteriaWithBetweenValue")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+        innerIterateElement.addElement(new TextElement(
+                "$oredCriteria[].criteriaWithBetweenValue[].condition$")); //$NON-NLS-1$
+        innerIterateElement
+                .addElement(new TextElement(
+                        "#oredCriteria[].criteriaWithBetweenValue[].values[0]# and")); //$NON-NLS-1$
+        innerIterateElement.addElement(new TextElement(
+                "#oredCriteria[].criteriaWithBetweenValue[].values[1]#")); //$NON-NLS-1$
+        isEqualElement.addElement(innerIterateElement);
+        
+        // if any of the columns have a user defined type handler, then we need
+        // to add additional inner iterate elements that specify the type handler
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
+            if (StringUtility.stringHasValue(introspectedColumn.getTypeHandler())) {
+                // name the property based on the column name, then
+                // add the type handler to the parameter declaration
+                StringBuilder sb1 = new StringBuilder();
+                StringBuilder sb2 = new StringBuilder();
+                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                
+                sb1.append("oredCriteria[]."); //$NON-NLS-1$
+                sb1.append(introspectedColumn.getJavaProperty());
+                sb1.append("CriteriaWithSingleValue"); //$NON-NLS-1$
+                
+                innerIterateElement.addAttribute(new Attribute(
+                        "property", sb1.toString())); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                
+                sb2.append(sb1);
+                
+                sb1.insert(0, '$');
+                sb1.append("[].condition$ ");//$NON-NLS-1$
+
+                sb2.insert(0, '#');
+                sb2.append("[].value,handler=");//$NON-NLS-1$
+                sb2.append(introspectedColumn.getTypeHandler());
+                sb2.append('#');
+                
+                sb1.append(sb2);
+                
+                innerIterateElement.addElement(new TextElement(sb1.toString()));
+                isEqualElement.addElement(innerIterateElement);
+                
+                sb1.setLength(0);
+                sb2.setLength(0);
+                sb1.append("oredCriteria[]."); //$NON-NLS-1$
+                sb1.append(introspectedColumn.getJavaProperty());
+                sb1.append("CriteriaWithListValue"); //$NON-NLS-1$
+
+                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                innerIterateElement.addAttribute(new Attribute(
+                        "property", sb1.toString())); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                
+                sb2.append('$');
+                sb2.append(sb1);
+                sb2.append("[].condition$"); //$NON-NLS-1$
+                
+                innerIterateElement.addElement(new TextElement(sb2.toString()));
+                
+                sb2.setLength(0);
+                sb2.append(sb1);
+                sb2.append("[].values"); //$NON-NLS-1$
+                
+                innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+                innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
+                        sb2.toString()));
+                innerInnerIterateElement.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
+                innerInnerIterateElement.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
+                innerInnerIterateElement
+                        .addAttribute(new Attribute("conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+                
+                sb2.setLength(0);
+                sb2.append('#');
+                sb2.append(sb1);
+                sb2.append("[].values[],handler="); //$NON-NLS-1$
+                sb2.append(introspectedColumn.getTypeHandler());
+                sb2.append('#');
+                
+                innerInnerIterateElement.addElement(new TextElement(sb2.toString()));
+                innerIterateElement.addElement(innerInnerIterateElement);
+                isEqualElement.addElement(innerIterateElement);
+
+                sb1.setLength(0);
+                sb2.setLength(0);
+                sb1.append("oredCriteria[]."); //$NON-NLS-1$
+                sb1.append(introspectedColumn.getJavaProperty());
+                sb1.append("CriteriaWithBetweenValue"); //$NON-NLS-1$
+
+                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                innerIterateElement.addAttribute(new Attribute(
+                        "property", sb1.toString())); //$NON-NLS-1$
+                innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
+                
+                sb2.append('$');
+                sb2.append(sb1);
+                sb2.append("[].condition$"); //$NON-NLS-1$
+                
+                innerIterateElement.addElement(new TextElement(sb2.toString()));
+                
+                sb2.setLength(0);
+                sb2.append(sb1);
+                
+                sb1.insert(0, '#');
+                sb1.append("[].values[0],handler="); //$NON-NLS-1$
+                sb1.append(introspectedColumn.getTypeHandler());
+                sb1.append("# and"); //$NON-NLS-1$
+                
+                sb2.insert(0, '#');
+                sb2.append("[].values[1],handler="); //$NON-NLS-1$
+                sb2.append(introspectedColumn.getTypeHandler());
+                sb2.append('#');
+                
+                innerIterateElement.addElement(new TextElement(sb1.toString()));
+                innerIterateElement.addElement(new TextElement(sb2.toString()));
+                isEqualElement.addElement(innerIterateElement);
+            }
+        }
+
+        isEqualElement.addElement(new TextElement(")")); //$NON-NLS-1$
+
+        if (ibatorContext.getPlugins().sqlMapExampleWhereClauseElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,110 @@
+/*
+ *  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.config.GeneratedKey;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class InsertElementGenerator extends XmlElementGeneratorBaseImpl {
+    
+    public InsertElementGenerator() {
+        super();
+    }
+    
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("insert"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        answer.addAttribute(new Attribute("id", XmlConstants.INSERT_STATEMENT_ID)); //$NON-NLS-1$
+        
+        FullyQualifiedJavaType parameterType =
+            introspectedTable.getRules().calculateAllFieldsClass();
+        
+        answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+                parameterType.getFullyQualifiedName()));
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        GeneratedKey gk = introspectedTable.getGeneratedKey();
+
+        if (gk != null && gk.isBeforeInsert()) {
+            IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
+            // if the column is null, then it's a configuration error. The
+            // warning has already been reported
+            if (introspectedColumn != null) {
+                // pre-generated key
+                answer.addElement(getSelectKey(introspectedColumn, gk));
+            }
+        }
+
+        StringBuilder insertClause = new StringBuilder();
+        StringBuilder valuesClause = new StringBuilder();
+
+        insertClause.append("insert into "); //$NON-NLS-1$
+        insertClause.append(table.getFullyQualifiedTableNameAtRuntime());
+        insertClause.append(" ("); //$NON-NLS-1$
+
+        valuesClause.append("values ("); //$NON-NLS-1$
+
+        boolean comma = false;
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
+            if (introspectedColumn.isIdentity()) {
+                // cannot set values on identity fields
+                continue;
+            }
+
+            if (comma) {
+                insertClause.append(", "); //$NON-NLS-1$
+                valuesClause.append(", "); //$NON-NLS-1$
+            } else {
+                comma = true; // turn on comma for next time
+            }
+
+            insertClause.append(introspectedColumn.getEscapedColumnName());
+            valuesClause.append(introspectedColumn.getIbatisFormattedParameterClause());
+        }
+        insertClause.append(')');
+        valuesClause.append(')');
+
+        answer.addElement(new TextElement(insertClause.toString()));
+        answer.addElement(new TextElement(valuesClause.toString()));
+
+        if (gk != null && !gk.isBeforeInsert()) {
+            IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
+            // if the column is null, then it's a configuration error. The
+            // warning has already been reported
+            if (introspectedColumn != null) {
+                // pre-generated key
+                answer.addElement(getSelectKey(introspectedColumn, gk));
+            }
+        }
+
+        if (ibatorContext.getPlugins().sqlMapInsertElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertSelectiveElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertSelectiveElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertSelectiveElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/InsertSelectiveElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,116 @@
+/*
+ *  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.config.GeneratedKey;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class InsertSelectiveElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public InsertSelectiveElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("insert"); //$NON-NLS-1$
+
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        answer.addAttribute(new Attribute("id", XmlConstants.INSERT_SELECTIVE_STATEMENT_ID)); //$NON-NLS-1$
+        
+        FullyQualifiedJavaType parameterType =
+            introspectedTable.getRules().calculateAllFieldsClass();
+        
+        answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+                parameterType.getFullyQualifiedName()));
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        GeneratedKey gk = introspectedTable.getGeneratedKey();
+
+        if (gk != null && gk.isBeforeInsert()) {
+            IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
+            // if the column is null, then it's a configuration error. The
+            // warning has already been reported
+            if (introspectedColumn != null) {
+                // pre-generated key
+                answer.addElement(getSelectKey(introspectedColumn, gk));
+            }
+        }
+        
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("insert into "); //$NON-NLS-1$
+        sb.append(table.getFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+        
+        XmlElement insertElement = new XmlElement("dynamic"); //$NON-NLS-1$
+        insertElement.addAttribute(new Attribute("prepend", "(")); //$NON-NLS-1$ //$NON-NLS-2$
+        answer.addElement(insertElement);
+        
+        answer.addElement(new TextElement("values")); //$NON-NLS-1$
+
+        XmlElement valuesElement = new XmlElement("dynamic"); //$NON-NLS-1$
+        valuesElement.addAttribute(new Attribute("prepend", "(")); //$NON-NLS-1$ //$NON-NLS-2$
+        answer.addElement(valuesElement);
+        
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
+            if (introspectedColumn.isIdentity()) {
+                // cannot set values on identity fields
+                continue;
+            }
+            
+            XmlElement insertNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+            insertNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+            insertNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+            insertNotNullElement.addElement(new TextElement(introspectedColumn.getEscapedColumnName()));
+            insertElement.addElement(insertNotNullElement);
+            
+            XmlElement valuesNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+            valuesNotNullElement.addAttribute(new Attribute("prepend", ",")); //$NON-NLS-1$ //$NON-NLS-2$
+            valuesNotNullElement.addAttribute(new Attribute("property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+            valuesNotNullElement.addElement(new TextElement(introspectedColumn.getIbatisFormattedParameterClause()));
+            valuesElement.addElement(valuesNotNullElement);
+        }
+        
+        insertElement.addElement(new TextElement(")")); //$NON-NLS-1$
+        valuesElement.addElement(new TextElement(")")); //$NON-NLS-1$
+        
+        if (gk != null && !gk.isBeforeInsert()) {
+            IntrospectedColumn introspectedColumn = introspectedTable.getColumn(gk.getColumn());
+            // if the column is null, then it's a configuration error. The
+            // warning has already been reported
+            if (introspectedColumn != null) {
+                // pre-generated key
+                answer.addElement(getSelectKey(introspectedColumn, gk));
+            }
+        }
+
+        if (ibatorContext.getPlugins().sqlMapInsertSelectiveElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithBLOBsElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithBLOBsElementGenerator.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 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.XmlElement;
+import org.apache.ibatis.ibator.config.PropertyRegistry;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class ResultMapWithBLOBsElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public ResultMapWithBLOBsElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        boolean useColumnIndex =
+            StringUtility.isTrue(introspectedTable.getTableConfigurationProperty(PropertyRegistry.TABLE_USE_COLUMN_INDEXES));
+
+        XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+        answer.addAttribute(new Attribute("id",  //$NON-NLS-1$
+                XmlConstants.RESULT_MAP_WITH_BLOBS_ID));
+        
+        FullyQualifiedJavaType returnType;
+        if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
+            returnType = introspectedTable.getRecordWithBLOBsType();
+        } else {
+            // table has BLOBs, but no BLOB class - BLOB fields must be
+            // in the base class
+            returnType = introspectedTable.getBaseRecordType();
+        }
+        
+        answer.addAttribute(new Attribute("class", //$NON-NLS-1$
+                returnType.getFullyQualifiedName()));
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(table.getSqlMapNamespace());
+        sb.append('.');
+        sb.append(XmlConstants.BASE_RESULT_MAP_ID);
+        answer.addAttribute(new Attribute("extends", sb.toString())); //$NON-NLS-1$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        int i = introspectedTable.getNonBLOBColumnCount() + 1;
+        if (StringUtility.stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())
+                || StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
+            i++;
+        }
+
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getBLOBColumns()) {
+            XmlElement resultElement = new XmlElement("result"); //$NON-NLS-1$
+            
+            if (useColumnIndex) {
+                resultElement.addAttribute(new Attribute(
+                        "columnIndex", Integer.toString(i++))); //$NON-NLS-1$
+            } else {
+                resultElement.addAttribute(new Attribute(
+                    "column", introspectedColumn.getRenamedColumnNameForResultMap())); //$NON-NLS-1$
+            }
+            resultElement.addAttribute(new Attribute(
+                    "property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+            resultElement.addAttribute(new Attribute(
+                    "jdbcType", introspectedColumn.getJdbcTypeName())); //$NON-NLS-1$
+
+            if (StringUtility.stringHasValue(introspectedColumn.getTypeHandler())) {
+                resultElement.addAttribute(new Attribute(
+                        "typeHandler", introspectedColumn.getTypeHandler())); //$NON-NLS-1$
+            }
+
+            answer.addElement(resultElement);
+        }
+
+        if (ibatorContext.getPlugins().sqlMapResultMapWithBLOBsElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithoutBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithoutBLOBsElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithoutBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/ResultMapWithoutBLOBsElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,90 @@
+/*
+ *  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.java.FullyQualifiedJavaType;
+import org.apache.ibatis.ibator.api.dom.xml.Attribute;
+import org.apache.ibatis.ibator.api.dom.xml.XmlElement;
+import org.apache.ibatis.ibator.config.PropertyRegistry;
+import org.apache.ibatis.ibator.generator.ibatis2.XmlConstants;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class ResultMapWithoutBLOBsElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public ResultMapWithoutBLOBsElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        boolean useColumnIndex =
+            StringUtility.isTrue(introspectedTable.getTableConfigurationProperty(PropertyRegistry.TABLE_USE_COLUMN_INDEXES));
+        XmlElement answer = new XmlElement("resultMap"); //$NON-NLS-1$
+        answer.addAttribute(new Attribute("id", //$NON-NLS-1$
+                XmlConstants.BASE_RESULT_MAP_ID));
+
+        FullyQualifiedJavaType returnType;
+        if (introspectedTable.getRules().generateBaseRecordClass()) {
+            returnType = introspectedTable.getBaseRecordType();
+        } else {
+            returnType = introspectedTable.getPrimaryKeyType();
+        }
+        
+        answer.addAttribute(new Attribute("class", //$NON-NLS-1$
+                returnType.getFullyQualifiedName()));
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        int i = 1;
+        if (StringUtility.stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())
+                || StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
+            i++;
+        }
+        
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
+            XmlElement resultElement = new XmlElement("result"); //$NON-NLS-1$
+
+            if (useColumnIndex) {
+                resultElement.addAttribute(new Attribute(
+                        "columnIndex", Integer.toString(i++))); //$NON-NLS-1$
+            } else {
+                resultElement.addAttribute(new Attribute(
+                    "column", introspectedColumn.getRenamedColumnNameForResultMap())); //$NON-NLS-1$
+            }
+            
+            resultElement.addAttribute(new Attribute(
+                    "property", introspectedColumn.getJavaProperty())); //$NON-NLS-1$
+            resultElement.addAttribute(new Attribute("jdbcType", //$NON-NLS-1$
+                    introspectedColumn.getJdbcTypeName()));
+
+            if (StringUtility.stringHasValue(introspectedColumn.getTypeHandler())) {
+                resultElement.addAttribute(new Attribute(
+                        "typeHandler", introspectedColumn.getTypeHandler())); //$NON-NLS-1$
+            }
+
+            answer.addElement(resultElement);
+        }
+
+        if (ibatorContext.getPlugins().sqlMapResultMapWithoutBLOBsElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithBLOBsElementGenerator.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 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;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class SelectByExampleWithBLOBsElementGenerator extends
+        XmlElementGeneratorBaseImpl {
+
+    public SelectByExampleWithBLOBsElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        FullyQualifiedJavaType fqjt = introspectedTable.getExampleType();
+
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "id", XmlConstants.SELECT_BY_EXAMPLE_WITH_BLOBS_STATEMENT_ID)); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "resultMap", XmlConstants.RESULT_MAP_WITH_BLOBS_ID)); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "parameterClass", fqjt.getFullyQualifiedName())); //$NON-NLS-1$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("select "); //$NON-NLS-1$
+
+        boolean comma = false;
+
+        if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
+            sb.append('\'');
+            sb.append(introspectedTable.getSelectByExampleQueryId());
+            sb.append("' as QUERYID"); //$NON-NLS-1$
+            comma = true;
+        }
+
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
+            if (comma) {
+                sb.append(", "); //$NON-NLS-1$
+            } else {
+                comma = true;
+            }
+
+            sb.append(introspectedColumn.getSelectListPhrase());
+        }
+        answer.addElement(new TextElement(sb.toString()));
+
+        sb.setLength(0);
+        sb.append("from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement(new TextElement(sb.toString()));
+
+        XmlElement isParameterPresenteElement =
+            new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        answer.addElement(isParameterPresenteElement);
+        
+        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$
+        isParameterPresenteElement.addElement(includeElement);
+
+        XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+        isNotNullElement
+                .addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
+        isNotNullElement
+                .addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
+        isParameterPresenteElement.addElement(isNotNullElement);
+
+        if (ibatorContext.getPlugins().sqlMapSelectByExampleWithBLOBsElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByExampleWithoutBLOBsElementGenerator.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 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;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class SelectByExampleWithoutBLOBsElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public SelectByExampleWithoutBLOBsElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+        FullyQualifiedJavaType fqjt = introspectedTable.getExampleType();
+
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+
+        answer.addAttribute(new Attribute("id", //$NON-NLS-1$
+                XmlConstants.SELECT_BY_EXAMPLE_STATEMENT_ID));
+        answer
+                .addAttribute(new Attribute(
+                        "resultMap", XmlConstants.BASE_RESULT_MAP_ID)); //$NON-NLS-1$
+        answer.addAttribute(new Attribute(
+                "parameterClass", fqjt.getFullyQualifiedName())); //$NON-NLS-1$
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("select "); //$NON-NLS-1$
+
+        boolean comma = false;
+        if (StringUtility.stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
+            sb.append('\'');
+            sb.append(introspectedTable.getSelectByExampleQueryId());
+            sb.append("' as QUERYID"); //$NON-NLS-1$
+            comma = true;
+        }
+
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getNonBLOBColumns()) {
+            if (comma) {
+                sb.append(", "); //$NON-NLS-1$
+            } else {
+                comma = true;
+            }
+
+            sb.append(introspectedColumn.getSelectListPhrase());
+        }
+        answer.addElement((new TextElement(sb.toString())));
+
+        sb.setLength(0);
+        sb.append("from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.addElement((new TextElement(sb.toString())));
+
+        XmlElement isParameterPresenteElement =
+            new XmlElement("isParameterPresent"); //$NON-NLS-1$
+        answer.addElement(isParameterPresenteElement);
+        
+        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$
+        isParameterPresenteElement.addElement(includeElement);
+
+        XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
+        isNotNullElement
+                .addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
+        isNotNullElement
+                .addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
+        isParameterPresenteElement.addElement(isNotNullElement);
+
+        if (ibatorContext.getPlugins().sqlMapSelectByExampleWithoutBLOBsElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByPrimaryKeyElementGenerator.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByPrimaryKeyElementGenerator.java?rev=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByPrimaryKeyElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/SelectByPrimaryKeyElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,114 @@
+/*
+ *  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;
+import org.apache.ibatis.ibator.internal.util.StringUtility;
+
+/**
+ * 
+ * @author Jeff Butler
+ *
+ */
+public class SelectByPrimaryKeyElementGenerator extends XmlElementGeneratorBaseImpl {
+
+    public SelectByPrimaryKeyElementGenerator() {
+        super();
+    }
+
+    public void addElements(XmlElement parentElement) {
+        XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
+        FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
+
+        answer.addAttribute(new Attribute(
+                "id", XmlConstants.SELECT_BY_PRIMARY_KEY_STATEMENT_ID)); //$NON-NLS-1$
+        if (introspectedTable.getRules().generateResultMapWithBLOBs()) {
+            answer.addAttribute(new Attribute("resultMap", //$NON-NLS-1$
+                    XmlConstants.RESULT_MAP_WITH_BLOBS_ID));
+        } else {
+            answer.addAttribute(new Attribute("resultMap", //$NON-NLS-1$
+                    XmlConstants.BASE_RESULT_MAP_ID));
+        }
+        
+        FullyQualifiedJavaType parameterType;
+        if (introspectedTable.getRules().generatePrimaryKeyClass()) {
+            parameterType = introspectedTable.getPrimaryKeyType();
+        } else {
+            // select by primary key, but no primary key class.  Fields
+            // must be in the base record
+            parameterType = introspectedTable.getBaseRecordType();
+        }
+        
+        answer.addAttribute(new Attribute("parameterClass", //$NON-NLS-1$
+                parameterType.getFullyQualifiedName()));
+
+        ibatorContext.getCommentGenerator().addComment(answer);
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("select "); //$NON-NLS-1$
+
+        boolean comma = false;
+        if (StringUtility.stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())) {
+            sb.append('\'');
+            sb.append(introspectedTable.getSelectByPrimaryKeyQueryId());
+            sb.append("' as QUERYID"); //$NON-NLS-1$
+            comma = true;
+        }
+
+        for (IntrospectedColumn introspectedColumn : introspectedTable.getAllColumns()) {
+            if (comma) {
+                sb.append(", "); //$NON-NLS-1$
+            } else {
+                comma = true;
+            }
+
+            sb.append(introspectedColumn.getSelectListPhrase());
+        }
+
+        answer.addElement(new TextElement(sb.toString()));
+
+        sb.setLength(0);
+        sb.append("from "); //$NON-NLS-1$
+        sb.append(table.getAliasedFullyQualifiedTableNameAtRuntime());
+        answer.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.getAliasedEscapedColumnName());
+            sb.append(" = "); //$NON-NLS-1$
+            sb.append(introspectedColumn.getIbatisFormattedParameterClause());
+            answer.addElement(new TextElement(sb.toString()));
+        }
+
+        if (ibatorContext.getPlugins().sqlMapSelectByPrimaryKeyElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}

Added: 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=703569&view=auto
==============================================================================
--- ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java (added)
+++ ibatis/trunk/java/tools/ibator/core/src/org/apache/ibatis/ibator/generator/ibatis2/sqlmap/elements/UpdateByExampleSelectiveElementGenerator.java Fri Oct 10 13:08:10 2008
@@ -0,0 +1,83 @@
+/*
+ *  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.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 UpdateByExampleSelectiveElementGenerator extends
+        XmlElementGeneratorBaseImpl {
+
+    public UpdateByExampleSelectiveElementGenerator() {
+        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_SELECTIVE_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()));
+
+        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.getAllColumns()) {
+            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("record."))); //$NON-NLS-1$ //$NON-NLS-2$
+            dynamicElement.addElement(isNotNullElement);
+
+            sb.setLength(0);
+            sb.append(introspectedColumn.getAliasedEscapedColumnName());
+            sb.append(" = "); //$NON-NLS-1$
+            sb.append(introspectedColumn.getIbatisFormattedParameterClause("record.")); //$NON-NLS-1$
+            
+            isNotNullElement.addElement(new TextElement(sb.toString()));
+        }
+
+        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().sqlMapUpdateByExampleSelectiveElementGenerated(answer, introspectedTable)) {
+            parentElement.addElement(answer);
+        }
+    }
+}



Mime
View raw message