Package org.apache.ibatis.abator.internal.rules

Provides the classes that implement Abator's code generation rules.

See:
          Description

Class Summary
AbatorRules This class centralizes all the rules related to code generation - including the methods and objects to create, and certain attributes related to those objects.
TableType Typesafe enum (from "Effective Java" #21) of table types supported by Abator.
 

Package org.apache.ibatis.abator.internal.rules Description

Provides the classes that implement Abator's code generation rules.

Code Generation Rules

Abator generates different objects and methods depending on the structure of the table, and configuration options set by the user. This document describes the rules.

Basic Assumptions

The rules classes assume that the following things are true (other layers of Abator enforce these rules):

Table Types

Abator defines different types of tables, based on the structure of the table. The table types are defined as follows:

Table Type Table has a Primary Key? Table has BLOB Fields? Table has non-BLOB fields not in the primary kay?
UNSUPPORTED - table with no columns No No No
TableType.NO_PK_FIELDS_NO_BLOBS No No Yes
UNSUPPORTED - table with only BLOB fields No Yes No
TableType.NO_PK_FIELDS_BLOBS No Yes Yes
TableType.PK_NO_FIELDS_NO_BLOBS Yes No No
TableType.PK_FIELDS_NO_BLOBS Yes No Yes
TableType.PK_NO_FIELDS_BLOBS Yes Yes No
TableType.PK_FIELDS_BLOBS Yes Yes Yes

SQL Map and DAO Method Rules

Abator generates different SQL Map elements based on the table type, and the user configuration. The following table describes what SQL Map elements will be generated based on the structure of the table. The notes following the table describe how user configuration options can alter these rules.

Table Type Result Map Without BLOBs? Result Map With BLOBs? SQL Example Where Clause? Select By Example Without BLOBs? Select By Example With BLOBs? Select By Primary Key? Insert? Update By Primary Key Without BLOBs? Update By Primary Key With BLOBs? Delete By Primary Key? Delete By Example?
NO_PK_FIELDS_NO_BLOBS Yes No Yes Yes No No Yes No No No Yes
NO_PK_FIELDS_BLOBS Yes Yes Yes Yes Yes No Yes No No No Yes
PK_NO_FIELDS_NO_BLOBS Yes No Yes Yes No No Yes No No Yes Yes
PK_FIELDS_NO_BLOBS Yes No Yes Yes No Yes Yes Yes No Yes Yes
PK_NO_FIELDS_BLOBS Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes
PK_FIELDS_BLOBS Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

Notes:

Domain Object Rules

Abator generates different domain objects based on the structure of the table. The following table describes the rules. One important note is that Abator will not include BLOB columns in the Example classes - because most databases do not support BLOB columns in the WHERE clause. In the table, we use the term "base record" to mean the class that holds the non-BLOB and non-Primary Key fields. The notes following the table describe how user configuration options can alter these rules.

Table Type Primary Key? Base Record Extending Primary Key? Base Record with no Super Class? Record with BLOBs Extending Primary Key? Record with BLOBs Extending Base Record? Example Extending Primary Key? Example Extending Base Record?
NO_PK_FIELDS_NO_BLOBS No No Yes No No No Yes
NO_PK_FIELDS_BLOBS No No Yes No Yes No Yes
PK_NO_FIELDS_NO_BLOBS Yes No No No No Yes No
PK_FIELDS_NO_BLOBS Yes Yes No No No No Yes
PK_NO_FIELDS_BLOBS Yes No No Yes No Yes No
PK_FIELDS_BLOBS Yes Yes No No Yes No Yes

Notes: