The <daoGenerator> element is used to define properties of the DAO generator. The DAO Generator builds DAOs in a variety of different formats - one DAO interface and implementation class for each introspected table. This element is a optional child element of the <abatorContext> element. If you do not specify this element, then Abator will not generate DAO interfaces and classes.
If you don't specify a user defined type, Abator will select a default
generator based on the value of the type attribute of this element and the
generatorSet
property of the
<abatorContext> element. See the notes on that
page for features of the different types of generators.
Attribute | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
type | This attribute is used to select one of the predefined DAO generators, or
to specify a user provided DAO generator.
Any user provided DAO generator must implement the interface
org.apache.ibatis.abator.api.DAOGenerator ,
and must have a public default constructor.
The attribute accepts the following four values for selecting one of the predefined DAO generators:
|
||||||||
targetPackage | This is the package where the generated DAO interfaces and classes will be placed. In the default generators, the property "enableSubPackages" controls how the actual package is calculated. If true, then the calculated package will be the targetPackage plus sub packages for the table's catalog and schema if they exist. If false (the default) then the calculated package will be exactly what is specified in the targetPackage attribute. Abator will create folders as required for the generated packages. | ||||||||
targetProject | This is used to specify a target project for the generated DAO interfaces and classes. When running in the Eclipse environment, this specifies the project and source folder where the objects will be saved. In other environments, this value should be an existing directory on the local file system. Abator will not create this directory if it does not exist. |
This table lists the properties of the default SQL Map generators that can be specified with the <property> child element:
Property Name | Property Values | ||||||||
---|---|---|---|---|---|---|---|---|---|
enableSubPackages | This property is used to select whether Abator will generate different
Java packages for the objects based on the catalog and schema of the
introspected table.
For example, suppose a table MYTABLE in schema MYSCHMA. Also suppose that the targetPackage attribute is set to "com.mycompany". If this property is true, the generated DAO interface and class for the table will be placed in the package "com.mycompany.myschema". If the property is false, the generated SQL Map will be placed in the "com.mycompany" schema. The default value is false. |
||||||||
exampleMethodVisibility | This property is used to set the visibility of the different "ByExample"
methods - selectByExample, deleteByExample, etc. If not specified, the
methods will be public and will be declared in the DAO interface.
This property allows you to hide these methods if you only want to use them
to implement other specialized DAO methods.
|
||||||||
methodNameCalculator | This property is used to select a method name calculator. A method name
calculator can be used to provide different names for the DAO methods.
You can select one of the predefined values, or you can specify the
fully qualified name of a class that implements the
org.apache.ibatis.abator.api.DAOMethodNameCalculator interface
if neither of the supplied options are appropriate in your environment.
|
||||||||
rootInterface | This property can be used to specify a super interface for all generated
DAO interface objects. This value may be overridden by specifying
the rootInterface property on a Table configuration.
Important: Abator does not verify that the interface exists, or is a valid Java interface. If specified, the value of this property should be a fully qualified interface name (like com.mycompany.MyRootInterface). |
This element specifies that we always want to place generated DAO interfaces and objects in the "'test.model" package and that we want to use subpackages based on the table schema and catalog. It also specifies that we want the generated DAO class to be compatible with the iBATIS DAO framework.
<daoGenerator targetPackage="test.model" targetProject="\MyProject\src" type="IBATIS"> <property name="enableSubPackages" value="true" /> </daoGenerator>