org.mybatis.generator.internal.rules
Class BaseRules

java.lang.Object
  extended by org.mybatis.generator.internal.rules.BaseRules
All Implemented Interfaces:
Rules
Direct Known Subclasses:
ConditionalModelRules, FlatModelRules, HierarchicalModelRules

public abstract class BaseRules
extends Object
implements Rules

This class centralizes all the rules related to code generation - including the methods and objects to create, and certain attributes related to those objects.

Author:
Jeff Butler

Field Summary
protected  IntrospectedTable introspectedTable
           
protected  boolean isModelOnly
           
protected  TableConfiguration tableConfiguration
           
 
Constructor Summary
BaseRules(IntrospectedTable introspectedTable)
           
 
Method Summary
 FullyQualifiedJavaType calculateAllFieldsClass()
          Calculates the class that contains all fields.
 boolean generateBaseColumnList()
          Implements the rule for generating the SQL base column list element.
 boolean generateBaseResultMap()
          Implements the rule for generating the result map without BLOBs.
 boolean generateBlobColumnList()
          Implements the rule for generating the SQL blob column list element.
 boolean generateCountByExample()
           
 boolean generateDeleteByExample()
          Implements the rule for generating the delete by example SQL Map element and DAO method.
 boolean generateDeleteByPrimaryKey()
          Implements the rule for generating the delete by primary key SQL Map element and DAO method.
 boolean generateExampleClass()
          Implements the rule for generating an example class.
 boolean generateInsert()
          Implements the rule for generating the insert SQL Map element and DAO method.
 boolean generateInsertSelective()
          Implements the rule for generating the insert selective SQL Map element and DAO method.
 boolean generateJavaClient()
          Implements the rule for generating a Java client.
 boolean generateMyBatis3UpdateByExampleWhereClause()
          Implements the rule for generating the SQL example where clause element specifically for use in the update by example methods.
 boolean generateResultMapWithBLOBs()
          Implements the rule for generating the result map with BLOBs.
 boolean generateSelectByExampleWithBLOBs()
          Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method.
 boolean generateSelectByExampleWithoutBLOBs()
          Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method.
 boolean generateSelectByPrimaryKey()
          Implements the rule for generating the select by primary key SQL Map element and DAO method.
 boolean generateSQLExampleWhereClause()
          Implements the rule for generating the SQL example where clause element.
 boolean generateUpdateByExampleSelective()
           
 boolean generateUpdateByExampleWithBLOBs()
           
 boolean generateUpdateByExampleWithoutBLOBs()
           
 boolean generateUpdateByPrimaryKeySelective()
          Implements the rule for generating the update by primary key selective SQL Map element and DAO method.
 boolean generateUpdateByPrimaryKeyWithBLOBs()
          Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method.
 boolean generateUpdateByPrimaryKeyWithoutBLOBs()
          Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method.
 IntrospectedTable getIntrospectedTable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mybatis.generator.internal.rules.Rules
generateBaseRecordClass, generatePrimaryKeyClass, generateRecordWithBLOBsClass
 

Field Detail

tableConfiguration

protected TableConfiguration tableConfiguration

introspectedTable

protected IntrospectedTable introspectedTable

isModelOnly

protected final boolean isModelOnly
Constructor Detail

BaseRules

public BaseRules(IntrospectedTable introspectedTable)
Method Detail

generateInsert

public boolean generateInsert()
Implements the rule for generating the insert SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.

Specified by:
generateInsert in interface Rules
Returns:
true if the element and method should be generated

generateInsertSelective

public boolean generateInsertSelective()
Implements the rule for generating the insert selective SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.

Specified by:
generateInsertSelective in interface Rules
Returns:
true if the element and method should be generated

calculateAllFieldsClass

public FullyQualifiedJavaType calculateAllFieldsClass()
Calculates the class that contains all fields. This class is used as the insert statement parameter, as well as the returned value from the select by primary key method. The actual class depends on how the domain model is generated.

Specified by:
calculateAllFieldsClass in interface Rules
Returns:
the type of the class that holds all fields

generateUpdateByPrimaryKeyWithoutBLOBs

public boolean generateUpdateByPrimaryKeyWithoutBLOBs()
Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method. If the table has a primary key as well as other non-BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Specified by:
generateUpdateByPrimaryKeyWithoutBLOBs in interface Rules
Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeyWithBLOBs

public boolean generateUpdateByPrimaryKeyWithBLOBs()
Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method. If the table has a primary key as well as other BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Specified by:
generateUpdateByPrimaryKeyWithBLOBs in interface Rules
Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeySelective

public boolean generateUpdateByPrimaryKeySelective()
Implements the rule for generating the update by primary key selective SQL Map element and DAO method. If the table has a primary key as well as other fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Specified by:
generateUpdateByPrimaryKeySelective in interface Rules
Returns:
true if the element and method should be generated

generateDeleteByPrimaryKey

public boolean generateDeleteByPrimaryKey()
Implements the rule for generating the delete by primary key SQL Map element and DAO method. If the table has a primary key, and the deleteByPrimaryKey statement is allowed, then generate the element and method.

Specified by:
generateDeleteByPrimaryKey in interface Rules
Returns:
true if the element and method should be generated

generateDeleteByExample

public boolean generateDeleteByExample()
Implements the rule for generating the delete by example SQL Map element and DAO method. If the deleteByExample statement is allowed, then generate the element and method.

Specified by:
generateDeleteByExample in interface Rules
Returns:
true if the element and method should be generated

generateBaseResultMap

public boolean generateBaseResultMap()
Implements the rule for generating the result map without BLOBs. If either select method is allowed, then generate the result map.

Specified by:
generateBaseResultMap in interface Rules
Returns:
true if the result map should be generated

generateResultMapWithBLOBs

public boolean generateResultMapWithBLOBs()
Implements the rule for generating the result map with BLOBs. If the table has BLOB columns, and either select method is allowed, then generate the result map.

Specified by:
generateResultMapWithBLOBs in interface Rules
Returns:
true if the result map should be generated

generateSQLExampleWhereClause

public boolean generateSQLExampleWhereClause()
Implements the rule for generating the SQL example where clause element. In iBATIS2, generate the element if the selectByExample, deleteByExample, updateByExample, or countByExample statements are allowed. In MyBatis3, generate the element if the selectByExample, deleteByExample, or countByExample statements are allowed.

Specified by:
generateSQLExampleWhereClause in interface Rules
Returns:
true if the SQL where clause element should be generated

generateMyBatis3UpdateByExampleWhereClause

public boolean generateMyBatis3UpdateByExampleWhereClause()
Implements the rule for generating the SQL example where clause element specifically for use in the update by example methods. In iBATIS2, do not generate the element. In MyBatis3, generate the element if the updateByExample statements are allowed.

Specified by:
generateMyBatis3UpdateByExampleWhereClause in interface Rules
Returns:
true if the SQL where clause element should be generated

generateSelectByPrimaryKey

public boolean generateSelectByPrimaryKey()
Implements the rule for generating the select by primary key SQL Map element and DAO method. If the table has a primary key as well as other fields, and the selectByPrimaryKey statement is allowed, then generate the element and method.

Specified by:
generateSelectByPrimaryKey in interface Rules
Returns:
true if the element and method should be generated

generateSelectByExampleWithoutBLOBs

public boolean generateSelectByExampleWithoutBLOBs()
Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method. If the selectByExample statement is allowed, then generate the element and method.

Specified by:
generateSelectByExampleWithoutBLOBs in interface Rules
Returns:
true if the element and method should be generated

generateSelectByExampleWithBLOBs

public boolean generateSelectByExampleWithBLOBs()
Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method. If the table has BLOB fields and the selectByExample statement is allowed, then generate the element and method.

Specified by:
generateSelectByExampleWithBLOBs in interface Rules
Returns:
true if the element and method should be generated

generateExampleClass

public boolean generateExampleClass()
Implements the rule for generating an example class. The class should be generated if the selectByExample or deleteByExample or countByExample methods are allowed.

Specified by:
generateExampleClass in interface Rules
Returns:
true if the example class should be generated

generateCountByExample

public boolean generateCountByExample()
Specified by:
generateCountByExample in interface Rules

generateUpdateByExampleSelective

public boolean generateUpdateByExampleSelective()
Specified by:
generateUpdateByExampleSelective in interface Rules

generateUpdateByExampleWithoutBLOBs

public boolean generateUpdateByExampleWithoutBLOBs()
Specified by:
generateUpdateByExampleWithoutBLOBs in interface Rules

generateUpdateByExampleWithBLOBs

public boolean generateUpdateByExampleWithBLOBs()
Specified by:
generateUpdateByExampleWithBLOBs in interface Rules

getIntrospectedTable

public IntrospectedTable getIntrospectedTable()
Specified by:
getIntrospectedTable in interface Rules

generateBaseColumnList

public boolean generateBaseColumnList()
Description copied from interface: Rules
Implements the rule for generating the SQL base column list element. Generate the element if any of the select methods are enabled.

Specified by:
generateBaseColumnList in interface Rules
Returns:
true if the SQL base column list element should be generated

generateBlobColumnList

public boolean generateBlobColumnList()
Description copied from interface: Rules
Implements the rule for generating the SQL blob column list element. Generate the element if any of the select methods are enabled, and the table contains BLOB columns.

Specified by:
generateBlobColumnList in interface Rules
Returns:
true if the SQL blob column list element should be generated

generateJavaClient

public boolean generateJavaClient()
Description copied from interface: Rules
Implements the rule for generating a Java client. This rule is only active when a javaClientGenerator configuration has been specified, but the table is designated as "modelOnly". Do not generate the client if the table is designated as modelOnly.

Specified by:
generateJavaClient in interface Rules
Returns:
true if the Java client should be generated


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