org.mybatis.generator.api.FullyQualifiedTable Java Examples

The following examples show how to use org.mybatis.generator.api.FullyQualifiedTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RowBoundsPlugin.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
/**
 * Use the method copy constructor to create a new element
 * 
 * @param fullyQualifiedTable
 * @param method
 */
private void copyAndSaveElement(XmlElement element, FullyQualifiedTable fqt) {
    XmlElement newElement = new XmlElement(element);
        
    // remove old id attribute and add a new one with the new name
    for (Iterator<Attribute> iterator = newElement.getAttributes().iterator(); iterator.hasNext();) {
        Attribute attribute = iterator.next();
        if ("id".equals(attribute.getName())) { //$NON-NLS-1$
            iterator.remove();
            Attribute newAttribute = new Attribute("id", attribute.getValue() + "WithRowbounds"); //$NON-NLS-1$ //$NON-NLS-2$
            newElement.addAttribute(newAttribute);
            break;
        }
    }
        
    // save the new element locally.   We'll add it to the document
    // later
    List<XmlElement> elements = elementsToAdd.get(fqt);
    if (elements == null) {
        elements = new ArrayList<XmlElement>();
        elementsToAdd.put(fqt, elements);
    }
    elements.add(newElement);
}
 
Example #2
Source File: DatabaseIntrospector.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
/**
 * Calls database metadata to retrieve extra information about the table
 * such as remarks associated with the table and the type.
 *
 * <p>If there is any error, we just add a warning and continue.
 *
 * @param introspectedTable the introspected table to enhance
 */
private void enhanceIntrospectedTable(IntrospectedTable introspectedTable) {
    try {
        FullyQualifiedTable fqt = introspectedTable.getFullyQualifiedTable();

        ResultSet rs = databaseMetaData.getTables(fqt.getIntrospectedCatalog(), fqt.getIntrospectedSchema(),
                fqt.getIntrospectedTableName(), null);
        if (rs.next()) {
            String remarks = rs.getString("REMARKS");
            String tableType = rs.getString("TABLE_TYPE");
            introspectedTable.setRemarks(remarks);
            introspectedTable.setTableType(tableType);
        }
        closeResultSet(rs);
    } catch (SQLException e) {
        warnings.add(getString("Warning.27", e.getMessage()));
    }
}
 
Example #3
Source File: RowBoundsPlugin.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
/**
 * Use the method copy constructor to create a new element
 * 
 * @param fullyQualifiedTable
 * @param method
 */
private void copyAndSaveElement(XmlElement element, FullyQualifiedTable fqt) {
    XmlElement newElement = new XmlElement(element);
        
    // remove old id attribute and add a new one with the new name
    for (Iterator<Attribute> iterator = newElement.getAttributes().iterator(); iterator.hasNext();) {
        Attribute attribute = iterator.next();
        if ("id".equals(attribute.getName())) { //$NON-NLS-1$
            iterator.remove();
            Attribute newAttribute = new Attribute("id", attribute.getValue() + "WithRowbounds"); //$NON-NLS-1$ //$NON-NLS-2$
            newElement.addAttribute(newAttribute);
            break;
        }
    }
        
    // save the new element locally.   We'll add it to the document
    // later
    List<XmlElement> elements = elementsToAdd.get(fqt);
    if (elements == null) {
        elements = new ArrayList<XmlElement>();
        elementsToAdd.put(fqt, elements);
    }
    elements.add(newElement);
}
 
Example #4
Source File: SimpleXMLMapperGenerator.java    From mybatis-generator-plus with Apache License 2.0 6 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addInsertElement(answer);
    addUpdateByPrimaryKeyElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addSelectAllElement(answer);

    return answer;
}
 
Example #5
Source File: SimpleXMLMapperGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addInsertElement(answer);
    addUpdateByPrimaryKeyElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addSelectAllElement(answer);

    return answer;
}
 
Example #6
Source File: SimpleXMLMapperGenerator.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.12", table.toString()));
    XmlElement answer = new XmlElement("mapper");
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace",
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addInsertElement(answer);
    addUpdateByPrimaryKeyElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addSelectAllElement(answer);

    return answer;
}
 
Example #7
Source File: RowBoundsPlugin.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
/**
 * Use the method copy constructor to create a new element.
 * 
 * @param fullyQualifiedTable the table
 * @param method the method
 */
private void copyAndSaveElement(XmlElement element, FullyQualifiedTable fqt) {
    XmlElement newElement = new XmlElement(element);

    // remove old id attribute and add a new one with the new name
    for (Iterator<Attribute> iterator = newElement.getAttributes().iterator(); iterator.hasNext();) {
        Attribute attribute = iterator.next();
        if ("id".equals(attribute.getName())) {
            iterator.remove();
            Attribute newAttribute =
                    new Attribute("id", attribute.getValue() + "WithRowbounds"); //$NON-NLS-2$
            newElement.addAttribute(newAttribute);
            break;
        }
    }

    // save the new element locally.   We'll add it to the document
    // later
    List<XmlElement> elements = elementsToAdd.computeIfAbsent(fqt, k -> new ArrayList<>());
    elements.add(newElement);
}
 
Example #8
Source File: DatabaseIntrospector.java    From mybatis-generator-core-fix with Apache License 2.0 6 votes vote down vote up
/**
 * This method calls database metadata to retrieve some extra information about the table
 * such as remarks associated with the table and the type.
 * 
 * If there is any error, we just add a warning and continue.
 * 
 * @param introspectedTable
 */
private void enhanceIntrospectedTable(IntrospectedTable introspectedTable) {
    try {
        FullyQualifiedTable fqt = introspectedTable.getFullyQualifiedTable();

        ResultSet rs = databaseMetaData.getTables(fqt.getIntrospectedCatalog(), fqt.getIntrospectedSchema(),
                fqt.getIntrospectedTableName(), null);
        if (rs.next()) {
            //获取字段备注信息
            String remarks = rs.getString("COMMENT"); //$NON-NLS-1$
            String tableType = rs.getString("TABLE_TYPE"); //$NON-NLS-1$
            introspectedTable.setRemarks(remarks);
            introspectedTable.setTableType(tableType);
        }
        closeResultSet(rs);
    } catch (SQLException e) {
        warnings.add(getString("Warning.27", e.getMessage())); //$NON-NLS-1$
    }
}
 
Example #9
Source File: DatabaseIntrospector.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
private void reportIntrospectionWarnings(
        IntrospectedTable introspectedTable,
        TableConfiguration tableConfiguration, FullyQualifiedTable table) {
    // make sure that every column listed in column overrides
    // actually exists in the table
    for (ColumnOverride columnOverride : tableConfiguration
            .getColumnOverrides()) {
        if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
            warnings.add(getString("Warning.3", //$NON-NLS-1$
                    columnOverride.getColumnName(), table.toString()));
        }
    }

    // make sure that every column listed in ignored columns
    // actually exists in the table
    for (String string : tableConfiguration.getIgnoredColumnsInError()) {
        warnings.add(getString("Warning.4", //$NON-NLS-1$
                string, table.toString()));
    }

    GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
    if (generatedKey != null
            && introspectedTable.getColumn(generatedKey.getColumn()) == null) {
        if (generatedKey.isIdentity()) {
            warnings.add(getString("Warning.5", //$NON-NLS-1$
                    generatedKey.getColumn(), table.toString()));
        } else {
            warnings.add(getString("Warning.6", //$NON-NLS-1$
                    generatedKey.getColumn(), table.toString()));
        }
    }
}
 
Example #10
Source File: XMLMapperGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addMyBatis3UpdateByExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(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;
}
 
Example #11
Source File: ObjectFactory.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
public static IntrospectedTable createIntrospectedTable(
        TableConfiguration tableConfiguration, FullyQualifiedTable table,
        Context context) {

    IntrospectedTable answer = createIntrospectedTableForValidation(context);
    answer.setFullyQualifiedTable(table);
    answer.setTableConfiguration(tableConfiguration);

    return answer;
}
 
Example #12
Source File: DAOGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.14", table.toString())); //$NON-NLS-1$
    TopLevelClass topLevelClass = getTopLevelClassShell();
    Interface interfaze = getInterfaceShell();

    addCountByExampleMethod(topLevelClass, interfaze);
    addDeleteByExampleMethod(topLevelClass, interfaze);
    addDeleteByPrimaryKeyMethod(topLevelClass, interfaze);
    addInsertMethod(topLevelClass, interfaze);
    addInsertSelectiveMethod(topLevelClass, interfaze);
    addSelectByExampleWithBLOBsMethod(topLevelClass, interfaze);
    addSelectByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
    addSelectByPrimaryKeyMethod(topLevelClass, interfaze);
    addUpdateByExampleParmsInnerclass(topLevelClass, interfaze);
    addUpdateByExampleSelectiveMethod(topLevelClass, interfaze);
    addUpdateByExampleWithBLOBsMethod(topLevelClass, interfaze);
    addUpdateByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeySelectiveMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeyWithBLOBsMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeyWithoutBLOBsMethod(topLevelClass, interfaze);

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().clientGenerated(interfaze,
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
        answer.add(interfaze);
    }

    return answer;
}
 
Example #13
Source File: DatabaseIntrospector.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
private void reportIntrospectionWarnings(
        IntrospectedTable introspectedTable,
        TableConfiguration tableConfiguration, FullyQualifiedTable table) {
    // make sure that every column listed in column overrides
    // actually exists in the table
    for (ColumnOverride columnOverride : tableConfiguration
            .getColumnOverrides()) {
        if (!introspectedTable.getColumn(columnOverride.getColumnName()).isPresent()) {
            warnings.add(getString("Warning.3",
                    columnOverride.getColumnName(), table.toString()));
        }
    }

    // make sure that every column listed in ignored columns
    // actually exists in the table
    for (String string : tableConfiguration.getIgnoredColumnsInError()) {
        warnings.add(getString("Warning.4",
                string, table.toString()));
    }

    GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
    if (generatedKey != null
            && !introspectedTable.getColumn(generatedKey.getColumn()).isPresent()) {
        if (generatedKey.isIdentity()) {
            warnings.add(getString("Warning.5",
                    generatedKey.getColumn(), table.toString()));
        } else {
            warnings.add(getString("Warning.6",
                    generatedKey.getColumn(), table.toString()));
        }
    }

    for (IntrospectedColumn ic : introspectedTable.getAllColumns()) {
        if (JavaReservedWords.containsWord(ic.getJavaProperty())) {
            warnings.add(getString("Warning.26",
                    ic.getActualColumnName(), table.toString()));
        }
    }
}
 
Example #14
Source File: SqlMapGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("sqlMap"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            introspectedTable.getIbatis2SqlMapNamespace()));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(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;
}
 
Example #15
Source File: SqlMapGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("sqlMap"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            introspectedTable.getIbatis2SqlMapNamespace()));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(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;
}
 
Example #16
Source File: DAOGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.14", table.toString())); //$NON-NLS-1$
    TopLevelClass topLevelClass = getTopLevelClassShell();
    Interface interfaze = getInterfaceShell();

    addCountByExampleMethod(topLevelClass, interfaze);
    addDeleteByExampleMethod(topLevelClass, interfaze);
    addDeleteByPrimaryKeyMethod(topLevelClass, interfaze);
    addInsertMethod(topLevelClass, interfaze);
    addInsertSelectiveMethod(topLevelClass, interfaze);
    addSelectByExampleWithBLOBsMethod(topLevelClass, interfaze);
    addSelectByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
    addSelectByPrimaryKeyMethod(topLevelClass, interfaze);
    addUpdateByExampleParmsInnerclass(topLevelClass, interfaze);
    addUpdateByExampleSelectiveMethod(topLevelClass, interfaze);
    addUpdateByExampleWithBLOBsMethod(topLevelClass, interfaze);
    addUpdateByExampleWithoutBLOBsMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeySelectiveMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeyWithBLOBsMethod(topLevelClass, interfaze);
    addUpdateByPrimaryKeyWithoutBLOBsMethod(topLevelClass, interfaze);

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().clientGenerated(interfaze,
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
        answer.add(interfaze);
    }

    return answer;
}
 
Example #17
Source File: DatabaseIntrospector.java    From mybatis-generator-core-fix with Apache License 2.0 5 votes vote down vote up
/**
 * Report introspection warnings.
 *
 * @param introspectedTable
 *            the introspected table
 * @param tableConfiguration
 *            the table configuration
 * @param table
 *            the table
 */
private void reportIntrospectionWarnings(
        IntrospectedTable introspectedTable,
        TableConfiguration tableConfiguration, FullyQualifiedTable table) {
    // make sure that every column listed in column overrides
    // actually exists in the table
    for (ColumnOverride columnOverride : tableConfiguration
            .getColumnOverrides()) {
        if (introspectedTable.getColumn(columnOverride.getColumnName()) == null) {
            warnings.add(getString("Warning.3", //$NON-NLS-1$
                    columnOverride.getColumnName(), table.toString()));
        }
    }

    // make sure that every column listed in ignored columns
    // actually exists in the table
    for (String string : tableConfiguration.getIgnoredColumnsInError()) {
        warnings.add(getString("Warning.4", //$NON-NLS-1$
                string, table.toString()));
    }

    GeneratedKey generatedKey = tableConfiguration.getGeneratedKey();
    if (generatedKey != null
            && introspectedTable.getColumn(generatedKey.getColumn()) == null) {
        if (generatedKey.isIdentity()) {
            warnings.add(getString("Warning.5", //$NON-NLS-1$
                    generatedKey.getColumn(), table.toString()));
        } else {
            warnings.add(getString("Warning.6", //$NON-NLS-1$
                    generatedKey.getColumn(), table.toString()));
        }
    }
    
    for (IntrospectedColumn ic : introspectedTable.getAllColumns()) {
        if (JavaReservedWords.containsWord(ic.getJavaProperty())) {
            warnings.add(getString("Warning.26", //$NON-NLS-1$
                    ic.getActualColumnName(), table.toString()));
        }
    }
}
 
Example #18
Source File: IntrospectedTableTools.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 设置DomainObjectName和MapperName
 * @param introspectedTable
 * @param context
 * @param domainObjectName
 */
public static void setDomainObjectName(IntrospectedTable introspectedTable, Context context, String domainObjectName) throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
    // 配置信息(没啥用)
    introspectedTable.getTableConfiguration().setDomainObjectName(domainObjectName);

    // FullyQualifiedTable修正
    Field domainObjectNameField = FullyQualifiedTable.class.getDeclaredField("domainObjectName");
    domainObjectNameField.setAccessible(true);
    domainObjectNameField.set(introspectedTable.getFullyQualifiedTable(), domainObjectName);

    // 重新修正introspectedTable属性信息
    Method calculateJavaClientAttributes = IntrospectedTable.class.getDeclaredMethod("calculateJavaClientAttributes");
    calculateJavaClientAttributes.setAccessible(true);
    calculateJavaClientAttributes.invoke(introspectedTable);

    Method calculateModelAttributes = IntrospectedTable.class.getDeclaredMethod("calculateModelAttributes");
    calculateModelAttributes.setAccessible(true);
    calculateModelAttributes.invoke(introspectedTable);

    Method calculateXmlAttributes = IntrospectedTable.class.getDeclaredMethod("calculateXmlAttributes");
    calculateXmlAttributes.setAccessible(true);
    calculateXmlAttributes.invoke(introspectedTable);

    // 注意!! 如果配置了ExampleTargetPlugin插件,要修正Example 位置
    PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
    if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
        String exampleType = introspectedTable.getExampleType();
        // 修改包名
        JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
        String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
        String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));

        introspectedTable.setExampleType(newExampleType);
    }
}
 
Example #19
Source File: XMLMapperGenerator.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString()));
    XmlElement answer = new XmlElement("mapper");
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace",
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addMyBatis3UpdateByExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(answer);
    addSelectByExampleWithBLOBsElement(answer);
    addSelectByExampleWithoutBLOBsElement(answer);
    addSelectByPrimaryKeyElement(answer);
    addDeleteByPrimaryKeyElement(answer);
    addDeleteByExampleElement(answer);
    addInsertElement(answer);
    addInsertBatchElement(answer);
    addInsertSelectiveElement(answer);
    addCountByExampleElement(answer);
    addUpdateByExampleSelectiveElement(answer);
    addUpdateByExampleWithBLOBsElement(answer);
    addUpdateByExampleWithoutBLOBsElement(answer);
    addUpdateByPrimaryKeySelectiveElement(answer);
    addUpdateByPrimaryKeyWithBLOBsElement(answer);
    addUpdateByPrimaryKeyWithoutBLOBsElement(answer);

    return answer;
}
 
Example #20
Source File: XMLMapperGenerator.java    From mybatis-generator-plus with Apache License 2.0 5 votes vote down vote up
protected XmlElement getSqlMapElement() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.12", table.toString())); //$NON-NLS-1$
    XmlElement answer = new XmlElement("mapper"); //$NON-NLS-1$
    String namespace = introspectedTable.getMyBatis3SqlMapNamespace();
    answer.addAttribute(new Attribute("namespace", //$NON-NLS-1$
            namespace));

    context.getCommentGenerator().addRootComment(answer);

    addResultMapWithoutBLOBsElement(answer);
    addResultMapWithBLOBsElement(answer);
    addExampleWhereClauseElement(answer);
    addMyBatis3UpdateByExampleWhereClauseElement(answer);
    addBaseColumnListElement(answer);
    addBlobColumnListElement(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;
}
 
Example #21
Source File: PrimaryKeyGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.7", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getPrimaryKeyType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    String rootClass = getRootClass();
    if (rootClass != null) {
        topLevelClass.setSuperClass(new FullyQualifiedJavaType(rootClass));
        topLevelClass.addImportedType(topLevelClass.getSuperClass());
    }

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getPrimaryKeyColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.PRIMARY_KEY)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelPrimaryKeyClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #22
Source File: BaseRecordGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }

    List<IntrospectedColumn> introspectedColumns = getColumnsInThisClass();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }
    
    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #23
Source File: RecordWithBLOBsGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.9", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getRecordWithBLOBsType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    if (introspectedTable.getRules().generateBaseRecordClass()) {
        topLevelClass.setSuperClass(introspectedTable.getBaseRecordType());
    } else {
        topLevelClass.setSuperClass(introspectedTable.getPrimaryKeyType());
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getBLOBColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addMethod(method);
        }

        method = getJavaBeansSetter(introspectedColumn);
        if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addMethod(method);
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelRecordWithBLOBsClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #24
Source File: BaseRecordGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getBaseRecordType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }

    List<IntrospectedColumn> introspectedColumns;
    if (includePrimaryKeyColumns()) {
        if (includeBLOBColumns()) {
            introspectedColumns = introspectedTable.getAllColumns();
        } else {
            introspectedColumns = introspectedTable.getNonBLOBColumns();
        }
    } else {
        if (includeBLOBColumns()) {
            introspectedColumns = introspectedTable
                    .getNonPrimaryKeyColumns();
        } else {
            introspectedColumns = introspectedTable.getBaseColumns();
        }
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        method = getJavaBeansSetter(introspectedColumn);
        if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #25
Source File: PrimaryKeyGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.7", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getPrimaryKeyType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    String rootClass = getRootClass();
    if (rootClass != null) {
        topLevelClass.setSuperClass(new FullyQualifiedJavaType(rootClass));
        topLevelClass.addImportedType(topLevelClass.getSuperClass());
    }

    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getPrimaryKeyColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addMethod(method);
        }

        method = getJavaBeansSetter(introspectedColumn);
        if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addMethod(method);
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelPrimaryKeyClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #26
Source File: SimpleModelGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }

    List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #27
Source File: RecordWithBLOBsGenerator.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.9", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getRecordWithBLOBsType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    String rootClass = getRootClass();
    if (introspectedTable.getRules().generateBaseRecordClass()) {
        topLevelClass.setSuperClass(introspectedTable.getBaseRecordType());
    } else {
        topLevelClass.setSuperClass(introspectedTable.getPrimaryKeyType());
    }

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }
    
    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getBLOBColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelRecordWithBLOBsClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
Example #28
Source File: DatabaseIntrospector.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
private List<IntrospectedTable> calculateIntrospectedTables(
        TableConfiguration tc,
        Map<ActualTableName, List<IntrospectedColumn>> columns) {
    boolean delimitIdentifiers = tc.isDelimitIdentifiers()
            || stringContainsSpace(tc.getCatalog())
            || stringContainsSpace(tc.getSchema())
            || stringContainsSpace(tc.getTableName());

    List<IntrospectedTable> answer = new ArrayList<IntrospectedTable>();

    for (Map.Entry<ActualTableName, List<IntrospectedColumn>> entry : columns
            .entrySet()) {
        ActualTableName atn = entry.getKey();

        // we only use the returned catalog and schema if something was
        // actually
        // specified on the table configuration. If something was returned
        // from the DB for these fields, but nothing was specified on the
        // table
        // configuration, then some sort of DB default is being returned
        // and we don't want that in our SQL
        FullyQualifiedTable table = new FullyQualifiedTable(
                stringHasValue(tc.getCatalog()) ? atn
                        .getCatalog() : null,
                stringHasValue(tc.getSchema()) ? atn
                        .getSchema() : null,
                atn.getTableName(),
                tc.getDomainObjectName(),
                tc.getAlias(),
                isTrue(tc.getProperty(PropertyRegistry.TABLE_IGNORE_QUALIFIERS_AT_RUNTIME)),
                tc.getProperty(PropertyRegistry.TABLE_RUNTIME_CATALOG),
                tc.getProperty(PropertyRegistry.TABLE_RUNTIME_SCHEMA),
                tc.getProperty(PropertyRegistry.TABLE_RUNTIME_TABLE_NAME),
                delimitIdentifiers, context);

        IntrospectedTable introspectedTable = ObjectFactory
                .createIntrospectedTable(tc, table, context);

        for (IntrospectedColumn introspectedColumn : entry.getValue()) {
            introspectedTable.addColumn(introspectedColumn);
        }

        calculatePrimaryKey(table, introspectedTable);

        answer.add(introspectedTable);
    }

    return answer;
}
 
Example #29
Source File: RowBoundsPlugin.java    From mybatis-generator-plus with Apache License 2.0 4 votes vote down vote up
public RowBoundsPlugin() {
    rowBounds = new FullyQualifiedJavaType("org.apache.ibatis.session.RowBounds"); //$NON-NLS-1$
    elementsToAdd = new HashMap<FullyQualifiedTable, List<XmlElement>>();
}
 
Example #30
Source File: BaseRecordGenerator.java    From mybatis-generator-core-fix with Apache License 2.0 4 votes vote down vote up
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);
    commentGenerator.addClassComment(topLevelClass, introspectedTable);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }
    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    List<IntrospectedColumn> introspectedColumns = getColumnsInThisClass();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }
    
    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}