org.mybatis.generator.api
Class IntrospectedTable

java.lang.Object
  extended by org.mybatis.generator.api.IntrospectedTable
Direct Known Subclasses:
IntrospectedTableIbatis2Java2Impl, IntrospectedTableMyBatis3Impl

public abstract class IntrospectedTable
extends Object

Base class for all code generator implementations. This class provides many of the housekeeping methods needed to implement a code generator, with only the actual code generation methods left unimplemented.

Author:
Jeff Butler

Nested Class Summary
protected static class IntrospectedTable.InternalAttribute
           
static class IntrospectedTable.TargetRuntime
           
 
Field Summary
protected  Map<String,Object> attributes
          Attributes may be used by plugins to capture table related state between the different plugin calls.
protected  List<IntrospectedColumn> baseColumns
           
protected  List<IntrospectedColumn> blobColumns
           
protected  Context context
           
protected  FullyQualifiedTable fullyQualifiedTable
           
protected  Map<IntrospectedTable.InternalAttribute,String> internalAttributes
          Internal attributes are used to store commonly accessed items by all code generators
protected  List<IntrospectedColumn> primaryKeyColumns
           
protected  Rules rules
           
protected  TableConfiguration tableConfiguration
           
protected  IntrospectedTable.TargetRuntime targetRuntime
           
 
Constructor Summary
IntrospectedTable(IntrospectedTable.TargetRuntime targetRuntime)
           
 
Method Summary
 void addColumn(IntrospectedColumn introspectedColumn)
           
 void addPrimaryKeyColumn(String columnName)
           
abstract  void calculateGenerators(List<String> warnings, ProgressCallback progressCallback)
          This method can be used to initialize the generators before they will be called.
protected  String calculateIbatis2SqlMapFileName()
           
protected  String calculateIbatis2SqlMapNamespace()
           
protected  void calculateJavaClientAttributes()
           
protected  String calculateJavaClientImplementationPackage()
           
protected  String calculateJavaClientInterfacePackage()
           
protected  String calculateJavaModelPackage()
           
protected  void calculateModelAttributes()
           
protected  String calculateMyBatis3FallbackSqlMapNamespace()
           
protected  String calculateMyBatis3XmlMapperFileName()
           
protected  String calculateSqlMapAliasedFullyQualifiedRuntimeTableName()
           
protected  String calculateSqlMapFullyQualifiedRuntimeTableName()
           
protected  String calculateSqlMapPackage()
           
protected  void calculateXmlAttributes()
           
 String getAliasedFullyQualifiedTableNameAtRuntime()
           
 List<IntrospectedColumn> getAllColumns()
          Returns all columns in the table (for use by the select by primary key and select by example with BLOBs methods)
 Object getAttribute(String name)
           
 String getBaseColumnListId()
           
 List<IntrospectedColumn> getBaseColumns()
           
 String getBaseRecordType()
           
 String getBaseResultMapId()
           
 String getBlobColumnListId()
           
 List<IntrospectedColumn> getBLOBColumns()
           
 IntrospectedColumn getColumn(String columnName)
           
 Context getContext()
           
 String getCountByExampleStatementId()
           
 String getDAOImplementationType()
           
 String getDAOInterfaceType()
           
 String getDeleteByExampleStatementId()
           
 String getDeleteByPrimaryKeyStatementId()
           
 String getExampleType()
           
 String getExampleWhereClauseId()
           
 FullyQualifiedTable getFullyQualifiedTable()
           
 String getFullyQualifiedTableNameAtRuntime()
           
abstract  List<GeneratedJavaFile> getGeneratedJavaFiles()
          This method should return a list of generated Java files related to this table.
 GeneratedKey getGeneratedKey()
           
abstract  List<GeneratedXmlFile> getGeneratedXmlFiles()
          This method should return a list of generated XML files related to this table.
abstract  int getGenerationSteps()
          This method should return the number of progress messages that will be send during the generation phase.
 String getIbatis2SqlMapFileName()
          Calculates an SQL Map file name for the table.
 String getIbatis2SqlMapNamespace()
           
 String getIbatis2SqlMapPackage()
          Calculates the package for the current table.
 String getInsertSelectiveStatementId()
           
 String getInsertStatementId()
           
 String getMyBatis3FallbackSqlMapNamespace()
           
 String getMyBatis3JavaMapperType()
           
 String getMyBatis3SqlMapNamespace()
           
 String getMyBatis3SqlProviderType()
           
 String getMyBatis3UpdateByExampleWhereClauseId()
           
 String getMyBatis3XmlMapperFileName()
           
 String getMyBatis3XmlMapperPackage()
           
 int getNonBLOBColumnCount()
           
 List<IntrospectedColumn> getNonBLOBColumns()
          Returns all columns except BLOBs (for use by the select by example without BLOBs method)
 List<IntrospectedColumn> getNonPrimaryKeyColumns()
           
 List<IntrospectedColumn> getPrimaryKeyColumns()
          Returns the columns in the primary key.
 String getPrimaryKeyType()
           
 String getRecordWithBLOBsType()
           
 String getResultMapWithBLOBsId()
           
 Rules getRules()
           
 String getSelectAllStatementId()
           
 String getSelectByExampleQueryId()
           
 String getSelectByExampleStatementId()
           
 String getSelectByExampleWithBLOBsStatementId()
           
 String getSelectByPrimaryKeyQueryId()
           
 String getSelectByPrimaryKeyStatementId()
           
 TableConfiguration getTableConfiguration()
           
 String getTableConfigurationProperty(String property)
           
 IntrospectedTable.TargetRuntime getTargetRuntime()
           
 String getUpdateByExampleSelectiveStatementId()
           
 String getUpdateByExampleStatementId()
           
 String getUpdateByExampleWithBLOBsStatementId()
           
 String getUpdateByPrimaryKeySelectiveStatementId()
           
 String getUpdateByPrimaryKeyStatementId()
           
 String getUpdateByPrimaryKeyWithBLOBsStatementId()
           
 boolean hasAnyColumns()
           
 boolean hasBaseColumns()
           
 boolean hasBLOBColumns()
           
 boolean hasJDBCDateColumns()
          Returns true if any of the columns in the table are JDBC Dates (as opposed to timestamps).
 boolean hasJDBCTimeColumns()
          Returns true if any of the columns in the table are JDBC Times (as opposed to timestamps).
 boolean hasPrimaryKeyColumns()
           
 void initialize()
           
 boolean isConstructorBased()
           
 boolean isImmutable()
           
abstract  boolean isJava5Targeted()
          Denotes whether generated code is targeted for Java version 5.0 or higher.
 void removeAttribute(String name)
           
abstract  boolean requiresXMLGenerator()
          Should return true if an XML generator is required for this table.
 void setAttribute(String name, Object value)
           
 void setBaseColumnListId(String s)
           
 void setBaseRecordType(String baseRecordType)
           
 void setBaseResultMapId(String s)
           
 void setBlobColumnListId(String s)
           
 void setContext(Context context)
           
 void setCountByExampleStatementId(String s)
           
 void setDAOImplementationType(String DAOImplementationType)
           
 void setDAOInterfaceType(String DAOInterfaceType)
           
 void setDeleteByExampleStatementId(String s)
           
 void setDeleteByPrimaryKeyStatementId(String s)
           
 void setExampleType(String exampleType)
           
 void setExampleWhereClauseId(String s)
           
 void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable)
           
 void setIbatis2SqlMapFileName(String sqlMapFileName)
           
 void setIbatis2SqlMapNamespace(String sqlMapNamespace)
           
 void setIbatis2SqlMapPackage(String sqlMapPackage)
           
 void setInsertSelectiveStatementId(String s)
           
 void setInsertStatementId(String s)
           
 void setMyBatis3FallbackSqlMapNamespace(String sqlMapNamespace)
           
 void setMyBatis3JavaMapperType(String mybatis3JavaMapperType)
           
 void setMyBatis3SqlProviderType(String mybatis3SqlProviderType)
           
 void setMyBatis3UpdateByExampleWhereClauseId(String s)
           
 void setMyBatis3XmlMapperFileName(String mybatis3XmlMapperFileName)
           
 void setMyBatis3XmlMapperPackage(String mybatis3XmlMapperPackage)
           
 void setPrimaryKeyType(String primaryKeyType)
           
 void setRecordWithBLOBsType(String recordWithBLOBsType)
           
 void setResultMapWithBLOBsId(String s)
           
 void setRules(Rules rules)
          This method exists to give plugins the opportunity to replace the calculated rules if necessary.
 void setSelectAllStatementId(String s)
           
 void setSelectByExampleStatementId(String s)
           
 void setSelectByExampleWithBLOBsStatementId(String s)
           
 void setSelectByPrimaryKeyStatementId(String s)
           
 void setSqlMapAliasedFullyQualifiedRuntimeTableName(String aliasedFullyQualifiedRuntimeTableName)
           
 void setSqlMapFullyQualifiedRuntimeTableName(String fullyQualifiedRuntimeTableName)
           
 void setTableConfiguration(TableConfiguration tableConfiguration)
           
 void setUpdateByExampleSelectiveStatementId(String s)
           
 void setUpdateByExampleStatementId(String s)
           
 void setUpdateByExampleWithBLOBsStatementId(String s)
           
 void setUpdateByPrimaryKeySelectiveStatementId(String s)
           
 void setUpdateByPrimaryKeyStatementId(String s)
           
 void setUpdateByPrimaryKeyWithBLOBsStatementId(String s)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableConfiguration

protected TableConfiguration tableConfiguration

fullyQualifiedTable

protected FullyQualifiedTable fullyQualifiedTable

context

protected Context context

rules

protected Rules rules

primaryKeyColumns

protected List<IntrospectedColumn> primaryKeyColumns

baseColumns

protected List<IntrospectedColumn> baseColumns

blobColumns

protected List<IntrospectedColumn> blobColumns

targetRuntime

protected IntrospectedTable.TargetRuntime targetRuntime

attributes

protected Map<String,Object> attributes
Attributes may be used by plugins to capture table related state between the different plugin calls.


internalAttributes

protected Map<IntrospectedTable.InternalAttribute,String> internalAttributes
Internal attributes are used to store commonly accessed items by all code generators

Constructor Detail

IntrospectedTable

public IntrospectedTable(IntrospectedTable.TargetRuntime targetRuntime)
Method Detail

getFullyQualifiedTable

public FullyQualifiedTable getFullyQualifiedTable()

getSelectByExampleQueryId

public String getSelectByExampleQueryId()

getSelectByPrimaryKeyQueryId

public String getSelectByPrimaryKeyQueryId()

getGeneratedKey

public GeneratedKey getGeneratedKey()

getColumn

public IntrospectedColumn getColumn(String columnName)

hasJDBCDateColumns

public boolean hasJDBCDateColumns()
Returns true if any of the columns in the table are JDBC Dates (as opposed to timestamps).

Returns:
true if the table contains DATE columns

hasJDBCTimeColumns

public boolean hasJDBCTimeColumns()
Returns true if any of the columns in the table are JDBC Times (as opposed to timestamps).

Returns:
true if the table contains TIME columns

getPrimaryKeyColumns

public List<IntrospectedColumn> getPrimaryKeyColumns()
Returns the columns in the primary key. If the generatePrimaryKeyClass() method returns false, then these columns will be iterated as the parameters of the selectByPrimaryKay and deleteByPrimaryKey methods

Returns:
a List of ColumnDefinition objects for columns in the primary key

hasPrimaryKeyColumns

public boolean hasPrimaryKeyColumns()

getBaseColumns

public List<IntrospectedColumn> getBaseColumns()

getAllColumns

public List<IntrospectedColumn> getAllColumns()
Returns all columns in the table (for use by the select by primary key and select by example with BLOBs methods)

Returns:
a List of ColumnDefinition objects for all columns in the table

getNonBLOBColumns

public List<IntrospectedColumn> getNonBLOBColumns()
Returns all columns except BLOBs (for use by the select by example without BLOBs method)

Returns:
a List of ColumnDefinition objects for columns in the table that are non BLOBs

getNonBLOBColumnCount

public int getNonBLOBColumnCount()

getNonPrimaryKeyColumns

public List<IntrospectedColumn> getNonPrimaryKeyColumns()

getBLOBColumns

public List<IntrospectedColumn> getBLOBColumns()

hasBLOBColumns

public boolean hasBLOBColumns()

hasBaseColumns

public boolean hasBaseColumns()

getRules

public Rules getRules()

getTableConfigurationProperty

public String getTableConfigurationProperty(String property)

getPrimaryKeyType

public String getPrimaryKeyType()

getBaseRecordType

public String getBaseRecordType()
Returns:
the type for the record (the class that holds non-primary key and non-BLOB fields). Note that the value will be calculated regardless of whether the table has these columns or not.

getExampleType

public String getExampleType()
Returns:
the type for the example class.

getRecordWithBLOBsType

public String getRecordWithBLOBsType()
Returns:
the type for the record with BLOBs class. Note that the value will be calculated regardless of whether the table has BLOB columns or not.

getIbatis2SqlMapFileName

public String getIbatis2SqlMapFileName()
Calculates an SQL Map file name for the table. Typically the name is "XXXX_SqlMap.xml" where XXXX is the fully qualified table name (delimited with underscores).

Returns:
the name of the SqlMap file

getIbatis2SqlMapNamespace

public String getIbatis2SqlMapNamespace()

getMyBatis3SqlMapNamespace

public String getMyBatis3SqlMapNamespace()

getMyBatis3FallbackSqlMapNamespace

public String getMyBatis3FallbackSqlMapNamespace()

getIbatis2SqlMapPackage

public String getIbatis2SqlMapPackage()
Calculates the package for the current table.

Returns:
the package for the SqlMap for the current table

getDAOImplementationType

public String getDAOImplementationType()

getDAOInterfaceType

public String getDAOInterfaceType()

hasAnyColumns

public boolean hasAnyColumns()

setTableConfiguration

public void setTableConfiguration(TableConfiguration tableConfiguration)

setFullyQualifiedTable

public void setFullyQualifiedTable(FullyQualifiedTable fullyQualifiedTable)

setContext

public void setContext(Context context)

addColumn

public void addColumn(IntrospectedColumn introspectedColumn)

addPrimaryKeyColumn

public void addPrimaryKeyColumn(String columnName)

getAttribute

public Object getAttribute(String name)

removeAttribute

public void removeAttribute(String name)

setAttribute

public void setAttribute(String name,
                         Object value)

initialize

public void initialize()

calculateXmlAttributes

protected void calculateXmlAttributes()

setBlobColumnListId

public void setBlobColumnListId(String s)

setBaseColumnListId

public void setBaseColumnListId(String s)

setExampleWhereClauseId

public void setExampleWhereClauseId(String s)

setMyBatis3UpdateByExampleWhereClauseId

public void setMyBatis3UpdateByExampleWhereClauseId(String s)

setResultMapWithBLOBsId

public void setResultMapWithBLOBsId(String s)

setBaseResultMapId

public void setBaseResultMapId(String s)

setUpdateByPrimaryKeyWithBLOBsStatementId

public void setUpdateByPrimaryKeyWithBLOBsStatementId(String s)

setUpdateByPrimaryKeySelectiveStatementId

public void setUpdateByPrimaryKeySelectiveStatementId(String s)

setUpdateByPrimaryKeyStatementId

public void setUpdateByPrimaryKeyStatementId(String s)

setUpdateByExampleWithBLOBsStatementId

public void setUpdateByExampleWithBLOBsStatementId(String s)

setUpdateByExampleSelectiveStatementId

public void setUpdateByExampleSelectiveStatementId(String s)

setUpdateByExampleStatementId

public void setUpdateByExampleStatementId(String s)

setSelectByPrimaryKeyStatementId

public void setSelectByPrimaryKeyStatementId(String s)

setSelectByExampleWithBLOBsStatementId

public void setSelectByExampleWithBLOBsStatementId(String s)

setSelectAllStatementId

public void setSelectAllStatementId(String s)

setSelectByExampleStatementId

public void setSelectByExampleStatementId(String s)

setInsertSelectiveStatementId

public void setInsertSelectiveStatementId(String s)

setInsertStatementId

public void setInsertStatementId(String s)

setDeleteByPrimaryKeyStatementId

public void setDeleteByPrimaryKeyStatementId(String s)

setDeleteByExampleStatementId

public void setDeleteByExampleStatementId(String s)

setCountByExampleStatementId

public void setCountByExampleStatementId(String s)

getBlobColumnListId

public String getBlobColumnListId()

getBaseColumnListId

public String getBaseColumnListId()

getExampleWhereClauseId

public String getExampleWhereClauseId()

getMyBatis3UpdateByExampleWhereClauseId

public String getMyBatis3UpdateByExampleWhereClauseId()

getResultMapWithBLOBsId

public String getResultMapWithBLOBsId()

getBaseResultMapId

public String getBaseResultMapId()

getUpdateByPrimaryKeyWithBLOBsStatementId

public String getUpdateByPrimaryKeyWithBLOBsStatementId()

getUpdateByPrimaryKeySelectiveStatementId

public String getUpdateByPrimaryKeySelectiveStatementId()

getUpdateByPrimaryKeyStatementId

public String getUpdateByPrimaryKeyStatementId()

getUpdateByExampleWithBLOBsStatementId

public String getUpdateByExampleWithBLOBsStatementId()

getUpdateByExampleSelectiveStatementId

public String getUpdateByExampleSelectiveStatementId()

getUpdateByExampleStatementId

public String getUpdateByExampleStatementId()

getSelectByPrimaryKeyStatementId

public String getSelectByPrimaryKeyStatementId()

getSelectByExampleWithBLOBsStatementId

public String getSelectByExampleWithBLOBsStatementId()

getSelectAllStatementId

public String getSelectAllStatementId()

getSelectByExampleStatementId

public String getSelectByExampleStatementId()

getInsertSelectiveStatementId

public String getInsertSelectiveStatementId()

getInsertStatementId

public String getInsertStatementId()

getDeleteByPrimaryKeyStatementId

public String getDeleteByPrimaryKeyStatementId()

getDeleteByExampleStatementId

public String getDeleteByExampleStatementId()

getCountByExampleStatementId

public String getCountByExampleStatementId()

calculateJavaClientImplementationPackage

protected String calculateJavaClientImplementationPackage()

calculateJavaClientInterfacePackage

protected String calculateJavaClientInterfacePackage()

calculateJavaClientAttributes

protected void calculateJavaClientAttributes()

calculateJavaModelPackage

protected String calculateJavaModelPackage()

calculateModelAttributes

protected void calculateModelAttributes()

calculateSqlMapPackage

protected String calculateSqlMapPackage()

calculateIbatis2SqlMapFileName

protected String calculateIbatis2SqlMapFileName()

calculateMyBatis3XmlMapperFileName

protected String calculateMyBatis3XmlMapperFileName()

calculateIbatis2SqlMapNamespace

protected String calculateIbatis2SqlMapNamespace()

calculateMyBatis3FallbackSqlMapNamespace

protected String calculateMyBatis3FallbackSqlMapNamespace()

calculateSqlMapFullyQualifiedRuntimeTableName

protected String calculateSqlMapFullyQualifiedRuntimeTableName()

calculateSqlMapAliasedFullyQualifiedRuntimeTableName

protected String calculateSqlMapAliasedFullyQualifiedRuntimeTableName()

getFullyQualifiedTableNameAtRuntime

public String getFullyQualifiedTableNameAtRuntime()

getAliasedFullyQualifiedTableNameAtRuntime

public String getAliasedFullyQualifiedTableNameAtRuntime()

calculateGenerators

public abstract void calculateGenerators(List<String> warnings,
                                         ProgressCallback progressCallback)
This method can be used to initialize the generators before they will be called. This method is called after all the setX methods, but before getNumberOfSubtasks(), getGeneratedJavaFiles, and getGeneratedXmlFiles.

Parameters:
warnings -
progressCallback -

getGeneratedJavaFiles

public abstract List<GeneratedJavaFile> getGeneratedJavaFiles()
This method should return a list of generated Java files related to this table. This list could include various types of model classes, as well as DAO classes.

Returns:
the list of generated Java files for this table

getGeneratedXmlFiles

public abstract List<GeneratedXmlFile> getGeneratedXmlFiles()
This method should return a list of generated XML files related to this table. Most implementations will only return one file - the generated SqlMap file.

Returns:
the list of generated XML files for this table

isJava5Targeted

public abstract boolean isJava5Targeted()
Denotes whether generated code is targeted for Java version 5.0 or higher.

Returns:
true if the generated code makes use of Java5 features

getGenerationSteps

public abstract int getGenerationSteps()
This method should return the number of progress messages that will be send during the generation phase.

Returns:
the number of progress messages

setRules

public void setRules(Rules rules)
This method exists to give plugins the opportunity to replace the calculated rules if necessary.

Parameters:
rules -

getTableConfiguration

public TableConfiguration getTableConfiguration()

setDAOImplementationType

public void setDAOImplementationType(String DAOImplementationType)

setDAOInterfaceType

public void setDAOInterfaceType(String DAOInterfaceType)

setPrimaryKeyType

public void setPrimaryKeyType(String primaryKeyType)

setBaseRecordType

public void setBaseRecordType(String baseRecordType)

setRecordWithBLOBsType

public void setRecordWithBLOBsType(String recordWithBLOBsType)

setExampleType

public void setExampleType(String exampleType)

setIbatis2SqlMapPackage

public void setIbatis2SqlMapPackage(String sqlMapPackage)

setIbatis2SqlMapFileName

public void setIbatis2SqlMapFileName(String sqlMapFileName)

setIbatis2SqlMapNamespace

public void setIbatis2SqlMapNamespace(String sqlMapNamespace)

setMyBatis3FallbackSqlMapNamespace

public void setMyBatis3FallbackSqlMapNamespace(String sqlMapNamespace)

setSqlMapFullyQualifiedRuntimeTableName

public void setSqlMapFullyQualifiedRuntimeTableName(String fullyQualifiedRuntimeTableName)

setSqlMapAliasedFullyQualifiedRuntimeTableName

public void setSqlMapAliasedFullyQualifiedRuntimeTableName(String aliasedFullyQualifiedRuntimeTableName)

getMyBatis3XmlMapperPackage

public String getMyBatis3XmlMapperPackage()

setMyBatis3XmlMapperPackage

public void setMyBatis3XmlMapperPackage(String mybatis3XmlMapperPackage)

getMyBatis3XmlMapperFileName

public String getMyBatis3XmlMapperFileName()

setMyBatis3XmlMapperFileName

public void setMyBatis3XmlMapperFileName(String mybatis3XmlMapperFileName)

getMyBatis3JavaMapperType

public String getMyBatis3JavaMapperType()

setMyBatis3JavaMapperType

public void setMyBatis3JavaMapperType(String mybatis3JavaMapperType)

getMyBatis3SqlProviderType

public String getMyBatis3SqlProviderType()

setMyBatis3SqlProviderType

public void setMyBatis3SqlProviderType(String mybatis3SqlProviderType)

getTargetRuntime

public IntrospectedTable.TargetRuntime getTargetRuntime()

isImmutable

public boolean isImmutable()

isConstructorBased

public boolean isConstructorBased()

requiresXMLGenerator

public abstract boolean requiresXMLGenerator()
Should return true if an XML generator is required for this table. This method will be called during validation of the configuration, so it should not rely on database introspection. This method simply tells the validator if an XML configuration is normally required for this implementation.

Returns:

getContext

public Context getContext()


Copyright © 2010-2012 MyBatis.org. All Rights Reserved.