org.apache.ibatis.abator.internal.java.dao
Class BaseDAOGenerator

java.lang.Object
  extended by org.apache.ibatis.abator.internal.java.dao.BaseDAOGenerator
All Implemented Interfaces:
DAOGenerator
Direct Known Subclasses:
BaseLegacyDAOGenerator, GenericCIJava2DAOGenerator, GenericCIJava5DAOGenerator, GenericSIJava2DAOGenerator, GenericSIJava5DAOGenerator, IbatisJava2DAOGenerator, IbatisJava5DAOGenerator, SpringJava2DAOGenerator, SpringJava5DAOGenerator

public class BaseDAOGenerator
extends java.lang.Object
implements DAOGenerator

This class generates DAO classes based on the values in the supplied DAOTemplate. This class supports the following properties:

enableSubPackages
If true, the classes will be generated in sub-packaged based on the database catalog and schema - else the will be generated in the specified package (the targetPackage attribute). Default is false.
rootInterface
If specified, then the root interface of the DAO interface class will be set to the specified value. No checking is done to see if the specified interface exists, or if the generated interface overrides any root interface methods.
exampleMethodVisibility
This property can be used the change the vilsibility of the various example methods (selectByExample, deleteByExample, etc.). If "public" (the default) then the implementation methods are public and the methods are declared in the interface declaration. If any of the other valid values (private, protected, default), then the methods have the specified visibility in the implmentation class and the methods are not declared in the interface class.
methodNameCalculator
This property can be used to specify different method name calculators. A method name calculator is used to create the DAO method names. Abator offers two choices - default, and extended. If you wish to supply a different version, you can specify the fully qualified name of a class that implements the org.apache.ibatis.abator.api.DAOMethodNameCalculator interface.

Author:
Jeff Butler

Field Summary
protected  AbatorContext abatorContext
           
protected  AbstractDAOTemplate daoTemplate
           
protected  JavaVisibility exampleMethodVisibility
           
protected  JavaModelGenerator javaModelGenerator
           
protected  DAOMethodNameCalculator methodNameCalculator
           
protected  java.util.Properties properties
           
protected  SqlMapGenerator sqlMapGenerator
           
protected  java.lang.String targetPackage
           
protected  java.lang.String targetProject
           
protected  java.util.List warnings
           
 
Constructor Summary
BaseDAOGenerator(AbstractDAOTemplate daoTemplate, boolean useJava5Features)
           
 
Method Summary
 void addConfigurationProperties(java.util.Properties properties)
          Adds properties for this instance from any properties configured in the DAOGeneratorConfiguration.
protected  void afterImplementationGenerationHook(IntrospectedTable introspectedTable, TopLevelClass generatedClass)
          Override this method to provide any extra customization of the generated implementation class.
protected  void afterInterfaceGenerationHook(IntrospectedTable introspectedTable, Interface generatedInterface)
          Override this method to provide any extra customization of the generated interface.
protected  java.util.List getCountByExampleMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  TopLevelClass getDAOImplementation(IntrospectedTable introspectedTable)
           
protected  FullyQualifiedJavaType getDAOImplementationType(FullyQualifiedTable table)
           
protected  Interface getDAOInterface(IntrospectedTable introspectedTable)
           
protected  FullyQualifiedJavaType getDAOInterfaceType(FullyQualifiedTable table)
           
protected  java.lang.String getDAOPackage(FullyQualifiedTable table)
           
protected  java.util.List getDeleteByExampleMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getDeleteByPrimaryKeyMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
 java.util.List getGeneratedJavaFiles(IntrospectedTable introspectedTable, ProgressCallback callback)
          This method returns a list of GenerateJavaFile objects.
protected  java.util.List getInsertMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getSelectByExampleWithBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getSelectByExampleWithoutBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getSelectByPrimaryKeyMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  InnerClass getUpdateByExampleParms(IntrospectedTable introspectedTable, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByExampleSelectiveMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByExampleWithBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByExampleWithoutBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByPrimaryKeySelectiveMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByPrimaryKeyWithBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
protected  java.util.List getUpdateByPrimaryKeyWithoutBLOBsMethods(IntrospectedTable introspectedTable, boolean interfaceMethod, CompilationUnit compilationUnit)
           
 void setAbatorContext(AbatorContext abatorContext)
          Sets the instance of the AbatorConfiguration object associated with this instance.
 void setJavaModelGenerator(JavaModelGenerator javaModelGenerator)
          Sets the instance of JavaModelGenerator associated with this instance.
 void setSqlMapGenerator(SqlMapGenerator sqlMapGenerator)
          Sets the instance of SqlMapGenerator associated with this instance.
 void setTargetPackage(java.lang.String targetPackage)
          Sets the target package for this instance.
 void setTargetProject(java.lang.String targetProject)
           
 void setWarnings(java.util.List warnings)
          Abator will supply a list to this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

abatorContext

protected AbatorContext abatorContext

daoTemplate

protected AbstractDAOTemplate daoTemplate

properties

protected java.util.Properties properties

warnings

protected java.util.List warnings

targetPackage

protected java.lang.String targetPackage

targetProject

protected java.lang.String targetProject

javaModelGenerator

protected JavaModelGenerator javaModelGenerator

sqlMapGenerator

protected SqlMapGenerator sqlMapGenerator

exampleMethodVisibility

protected JavaVisibility exampleMethodVisibility

methodNameCalculator

protected DAOMethodNameCalculator methodNameCalculator
Constructor Detail

BaseDAOGenerator

public BaseDAOGenerator(AbstractDAOTemplate daoTemplate,
                        boolean useJava5Features)
Method Detail

addConfigurationProperties

public void addConfigurationProperties(java.util.Properties properties)
Description copied from interface: DAOGenerator
Adds properties for this instance from any properties configured in the DAOGeneratorConfiguration. This method will be called before any of the get methods.

Specified by:
addConfigurationProperties in interface DAOGenerator
Parameters:
properties - All properties from the configuration

setWarnings

public void setWarnings(java.util.List warnings)
Description copied from interface: DAOGenerator
Abator will supply a list to this method. The implementation class may add strings to the list that will be treated as warning messages and displayed to the user. The concept of a warning is that code generation can continue, but that the results may not be what is expected.

Specified by:
setWarnings in interface DAOGenerator

setTargetPackage

public void setTargetPackage(java.lang.String targetPackage)
Description copied from interface: DAOGenerator
Sets the target package for this instance. This value should be used to calculate the package for the DAO interface and implementation classes. This method will be called before any of the get methods.

Specified by:
setTargetPackage in interface DAOGenerator
Parameters:
targetPackage - The target package from the configuration

setTargetProject

public void setTargetProject(java.lang.String targetProject)
Specified by:
setTargetProject in interface DAOGenerator

setJavaModelGenerator

public void setJavaModelGenerator(JavaModelGenerator javaModelGenerator)
Description copied from interface: DAOGenerator
Sets the instance of JavaModelGenerator associated with this instance. This method will be called before any of the get methods.

Specified by:
setJavaModelGenerator in interface DAOGenerator
Parameters:
javaModelGenerator - The JavaModelGenerator associated with this instance

setSqlMapGenerator

public void setSqlMapGenerator(SqlMapGenerator sqlMapGenerator)
Description copied from interface: DAOGenerator
Sets the instance of SqlMapGenerator associated with this instance. This method will be called before any of the get methods.

Specified by:
setSqlMapGenerator in interface DAOGenerator
Parameters:
sqlMapGenerator - The SqlMapGenerator associated with this instance

getGeneratedJavaFiles

public java.util.List getGeneratedJavaFiles(IntrospectedTable introspectedTable,
                                            ProgressCallback callback)
Description copied from interface: DAOGenerator
This method returns a list of GenerateJavaFile objects. The list may include any, or all, of the following types of generated java classes:

Specified by:
getGeneratedJavaFiles in interface DAOGenerator
Returns:
a list of GeneratedJavaFile objects

getDAOImplementation

protected TopLevelClass getDAOImplementation(IntrospectedTable introspectedTable)

afterInterfaceGenerationHook

protected void afterInterfaceGenerationHook(IntrospectedTable introspectedTable,
                                            Interface generatedInterface)
Override this method to provide any extra customization of the generated interface.

Parameters:
introspectedTable -
generatedInterface - the generated interface

afterImplementationGenerationHook

protected void afterImplementationGenerationHook(IntrospectedTable introspectedTable,
                                                 TopLevelClass generatedClass)
Override this method to provide any extra customization of the generated implementation class.

Parameters:
introspectedTable -
generatedClass - the generated class

getDAOInterface

protected Interface getDAOInterface(IntrospectedTable introspectedTable)

getDAOImplementationType

protected FullyQualifiedJavaType getDAOImplementationType(FullyQualifiedTable table)

getInsertMethods

protected java.util.List getInsertMethods(IntrospectedTable introspectedTable,
                                          boolean interfaceMethod,
                                          CompilationUnit compilationUnit)

getUpdateByPrimaryKeyWithoutBLOBsMethods

protected java.util.List getUpdateByPrimaryKeyWithoutBLOBsMethods(IntrospectedTable introspectedTable,
                                                                  boolean interfaceMethod,
                                                                  CompilationUnit compilationUnit)

getUpdateByPrimaryKeyWithBLOBsMethods

protected java.util.List getUpdateByPrimaryKeyWithBLOBsMethods(IntrospectedTable introspectedTable,
                                                               boolean interfaceMethod,
                                                               CompilationUnit compilationUnit)

getUpdateByPrimaryKeySelectiveMethods

protected java.util.List getUpdateByPrimaryKeySelectiveMethods(IntrospectedTable introspectedTable,
                                                               boolean interfaceMethod,
                                                               CompilationUnit compilationUnit)

getSelectByExampleWithoutBLOBsMethods

protected java.util.List getSelectByExampleWithoutBLOBsMethods(IntrospectedTable introspectedTable,
                                                               boolean interfaceMethod,
                                                               CompilationUnit compilationUnit)

getSelectByExampleWithBLOBsMethods

protected java.util.List getSelectByExampleWithBLOBsMethods(IntrospectedTable introspectedTable,
                                                            boolean interfaceMethod,
                                                            CompilationUnit compilationUnit)

getSelectByPrimaryKeyMethods

protected java.util.List getSelectByPrimaryKeyMethods(IntrospectedTable introspectedTable,
                                                      boolean interfaceMethod,
                                                      CompilationUnit compilationUnit)

getDeleteByExampleMethods

protected java.util.List getDeleteByExampleMethods(IntrospectedTable introspectedTable,
                                                   boolean interfaceMethod,
                                                   CompilationUnit compilationUnit)

getDeleteByPrimaryKeyMethods

protected java.util.List getDeleteByPrimaryKeyMethods(IntrospectedTable introspectedTable,
                                                      boolean interfaceMethod,
                                                      CompilationUnit compilationUnit)

getCountByExampleMethods

protected java.util.List getCountByExampleMethods(IntrospectedTable introspectedTable,
                                                  boolean interfaceMethod,
                                                  CompilationUnit compilationUnit)

getDAOPackage

protected java.lang.String getDAOPackage(FullyQualifiedTable table)

getDAOInterfaceType

protected FullyQualifiedJavaType getDAOInterfaceType(FullyQualifiedTable table)

setAbatorContext

public void setAbatorContext(AbatorContext abatorContext)
Description copied from interface: DAOGenerator
Sets the instance of the AbatorConfiguration object associated with this instance. This method will be called before any of the get methods.

Specified by:
setAbatorContext in interface DAOGenerator
Parameters:
abatorContext - The current AbatorContext

getUpdateByExampleSelectiveMethods

protected java.util.List getUpdateByExampleSelectiveMethods(IntrospectedTable introspectedTable,
                                                            boolean interfaceMethod,
                                                            CompilationUnit compilationUnit)

getUpdateByExampleParms

protected InnerClass getUpdateByExampleParms(IntrospectedTable introspectedTable,
                                             CompilationUnit compilationUnit)

getUpdateByExampleWithBLOBsMethods

protected java.util.List getUpdateByExampleWithBLOBsMethods(IntrospectedTable introspectedTable,
                                                            boolean interfaceMethod,
                                                            CompilationUnit compilationUnit)

getUpdateByExampleWithoutBLOBsMethods

protected java.util.List getUpdateByExampleWithoutBLOBsMethods(IntrospectedTable introspectedTable,
                                                               boolean interfaceMethod,
                                                               CompilationUnit compilationUnit)