// Path: src/main/java/org/mybatis/generator/internal/db/DatabaseDialects.java
// public enum DatabaseDialects {
// 
//     DB2("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     MYSQL("SELECT LAST_INSERT_ID()"), //$NON-NLS-1$
//     SQLSERVER("SELECT SCOPE_IDENTITY()"), //$NON-NLS-1$
//     CLOUDSCAPE("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     DERBY("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     HSQLDB("CALL IDENTITY()"), //$NON-NLS-1$
//     SYBASE("SELECT @@IDENTITY"), //$NON-NLS-1$
//     DB2_MF("SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1"), //$NON-NLS-1$
//     INFORMIX("select dbinfo('sqlca.sqlerrd1') from systables where tabid=1"); //$NON-NLS-1$
// 
//     private String identityRetrievalStatement;
// 
//     /**
//      *  
//      */
//     private DatabaseDialects(String identityRetrievalStatement) {
//         this.identityRetrievalStatement = identityRetrievalStatement;
//     }
// 
//     public String getIdentityRetrievalStatement() {
//         return identityRetrievalStatement;
//     }
// 
//     /**
//      * 
//      * @param database
//      * @return the database dialect for the selected database. May return null
//      *         if there is no known dialect for the selected db
//      */
//     public static DatabaseDialects getDatabaseDialect(String database) {
//         DatabaseDialects returnValue = null;
// 
//         if ("DB2".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DB2;
//         } else if ("MySQL".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = MYSQL;
//         } else if ("SqlServer".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = SQLSERVER;
//         } else if ("Cloudscape".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = CLOUDSCAPE;
//         } else if ("Derby".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DERBY;
//         } else if ("HSQLDB".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = HSQLDB;
//         } else if ("SYBASE".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = SYBASE;
//         } else if ("DB2_MF".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DB2_MF;
//         } else if ("Informix".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = INFORMIX;
//         }
// 
//         return returnValue;
//     }
// }


import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.List;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.internal.db.DatabaseDialects;
     * 
     * @return
     */
    public boolean isPlacedBeforeInsertInIbatis2() {
        boolean rc;
        
        if (stringHasValue(type)) {
            rc = true;
        } else {
            rc = !isIdentity;
        }
        
        return rc;
    }
    
    public String getMyBatis3Order() {
        return isIdentity ? "AFTER" : "BEFORE"; //$NON-NLS-1$ //$NON-NLS-2$
    }
    
    public XmlElement toXmlElement() {
        XmlElement xmlElement = new XmlElement("generatedKey"); //$NON-NLS-1$
        xmlElement.addAttribute(new Attribute("column", column)); //$NON-NLS-1$
        xmlElement.addAttribute(new Attribute(
                "sqlStatement", configuredSqlStatement)); //$NON-NLS-1$
        if (stringHasValue(type)) {
            xmlElement.addAttribute(new Attribute("type", type)); //$NON-NLS-1$
        }
        xmlElement.addAttribute(new Attribute("identity", //$NON-NLS-1$
                isIdentity ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$

// Path: src/main/java/org/mybatis/generator/internal/db/DatabaseDialects.java
// public enum DatabaseDialects {
// 
//     DB2("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     MYSQL("SELECT LAST_INSERT_ID()"), //$NON-NLS-1$
//     SQLSERVER("SELECT SCOPE_IDENTITY()"), //$NON-NLS-1$
//     CLOUDSCAPE("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     DERBY("VALUES IDENTITY_VAL_LOCAL()"), //$NON-NLS-1$
//     HSQLDB("CALL IDENTITY()"), //$NON-NLS-1$
//     SYBASE("SELECT @@IDENTITY"), //$NON-NLS-1$
//     DB2_MF("SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1"), //$NON-NLS-1$
//     INFORMIX("select dbinfo('sqlca.sqlerrd1') from systables where tabid=1"); //$NON-NLS-1$
// 
//     private String identityRetrievalStatement;
// 
//     /**
//      *  
//      */
//     private DatabaseDialects(String identityRetrievalStatement) {
//         this.identityRetrievalStatement = identityRetrievalStatement;
//     }
// 
//     public String getIdentityRetrievalStatement() {
//         return identityRetrievalStatement;
//     }
// 
//     /**
//      * 
//      * @param database
//      * @return the database dialect for the selected database. May return null
//      *         if there is no known dialect for the selected db
//      */
//     public static DatabaseDialects getDatabaseDialect(String database) {
//         DatabaseDialects returnValue = null;
// 
//         if ("DB2".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DB2;
//         } else if ("MySQL".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = MYSQL;
//         } else if ("SqlServer".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = SQLSERVER;
//         } else if ("Cloudscape".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = CLOUDSCAPE;
//         } else if ("Derby".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DERBY;
//         } else if ("HSQLDB".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = HSQLDB;
//         } else if ("SYBASE".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = SYBASE;
//         } else if ("DB2_MF".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = DB2_MF;
//         } else if ("Informix".equalsIgnoreCase(database)) { //$NON-NLS-1$
//             returnValue = INFORMIX;
//         }
// 
//         return returnValue;
//     }
// }


// Path: src/main/java/org/mybatis/generator/config/GeneratedKey.java
import static org.mybatis.generator.internal.util.StringUtility.stringHasValue;
import static org.mybatis.generator.internal.util.messages.Messages.getString;
import java.util.List;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.XmlElement;
import org.mybatis.generator.internal.db.DatabaseDialects;

     * 
     * @return
     */
    public boolean isPlacedBeforeInsertInIbatis2() {
        boolean rc;
        
        if (stringHasValue(type)) {
            rc = true;
        } else {
            rc = !isIdentity;
        }
        
        return rc;
    }
    
    public String getMyBatis3Order() {
        return isIdentity ? "AFTER" : "BEFORE"; //$NON-NLS-1$ //$NON-NLS-2$
    }
    
    public XmlElement toXmlElement() {
        XmlElement xmlElement = new XmlElement("generatedKey"); //$NON-NLS-1$
        xmlElement.addAttribute(new Attribute("column", column)); //$NON-NLS-1$
        xmlElement.addAttribute(new Attribute(
                "sqlStatement", configuredSqlStatement)); //$NON-NLS-1$
        if (stringHasValue(type)) {
            xmlElement.addAttribute(new Attribute("type", type)); //$NON-NLS-1$
        }
        xmlElement.addAttribute(new Attribute("identity", //$NON-NLS-1$
                isIdentity ? "true" : "false")); //$NON-NLS-1$ //$NON-NLS-2$

        return xmlElement;