Abator Generated Java Model Classes

Abator generates Java classes that correspond to the fields in a database table. The generated classes are a type of domain object, but should in no way be confused with a rich domain model (see the Philosophy page for more on this subject). Abator generates different types of "domain" objects based on the characteristics of the table.

Every field and method generated by Abator includes the non-standard JavaDoc tag @abatorgenerated. On subsequent runs of Abator, every field and method that includes this JavaDoc tag will be deleted and replaced. Any other field or method in the class will be untouched by Abator. With this in mind, you can add other fields and methods to the classes without fear of losing them in subsequent runs of Abator - simply DO NOT include the @abatorgenerated JavaDoc tag on anything that you add to the class.

The following sections describe the different types of "domain" classes that will be generated by Abator.

Any column ignored by an <ignoreColumn> configuration element will by ignored and not added to any generated Java class.

Note: in the following descriptions, the term "BLOB" is used to refer to any column with a data type of BLOB, CLOB, LONGVARCHAR, or LONGVARBINARY.

Primary Key Class

This class will contain properties for each field in the primary key of a table. The property names will be generated automtically by Abator, and based on the column name in the table. The abator generated property names can be overridded with a <columnOverride> configuration element.

The name of the class will be «TableName»Key by default, or «domainObjectName»Key if the domainObjectName attribute is specified on the <table> configuration element.

This class will be generated if the table has a primary key.

Record Class

This class will contain properties for each non-BLOB and non-primary key column in the table. The class will extend the primary key class, if there is a primary key. The property names will be generated automtically by Abator, and based on the column name in the table. The abator generated property names can be overridded with a <columnOverride> configuration element.

The name of the class will be «TableName» by default, or «domainObjectName» if the domainObjectName attribute is specified on the <table> configuration element.

This class will be generated if the table has non-BLOB and non-primary key columns.

Record With BLOBs Class

This class will contain properties for each BLOB column in the table. The class will extend the record class, if there are other non-BLOB and non-Primary Key columns in the table, else it will extend the primary key (note that Abator does not support tables that only contain BLOB columns). The property names will be generated automtically by Abator, and based on the column name in the table. The abator generated property names can be overridded with a <columnOverride> configuration element.

This class will be the return value from the selectByPrimaryKey method, or the selectByExampleWithBLOBs method.

The name of the class will be «TableName»WithBLOBs by default, or «domainObjectName»WithBLOBs if the domainObjectName attribute is specified on the <table> configuration element.

This class will be generated if the table has any BLOB columns.

Example Class

This class is used to specify "query by example" indicators for the selectByExample, selectByExampleWithBLOBs, and deleteByExample methods. This class extends either the record class (without BLOBs), or the primary key class depending on the attributes of the table.

The name of the class will be «TableName»Example by default, or «domainObjectName»Example if the domainObjectName attribute is specified on the <table> configuration element.

This class will be generated if the selectByExample or deleteByExample methods are enabled.

Example Class Usage Notes

The example class specifies how to build a dynamic where clause. Each non-BLOB column in the can can optionally be included in the where clause, and several different operators are available to specify how the different query constraints should work. Probably an example is the best way to demonstrate the usage of this class:

  TestTableExample example = new TestTableExample();
  example.setField1("Fred");
  example.setField1_Indicator(TestTableExample.EXAMPLE_EQUALS);
  example.setField2(22);
  example.setField2_Indicator(TestTableExample.EXAMPLE_GREATER_THAN);
  example.setField3_Indicator(TestTableExample.EXAMPLE_NULL);
  
  List results = testTableDAO.selectByExample(example);

In the above example, the dynamically generated where clause will effectively be:

  where field1 = 'Fred' and field2 > 22 and field3 is null

Returned records will meet these criteria.

Note that the default combination is AND. If you want to use OR instead, the you can call the method setCombineTypeOr(true) on the example class.

The available indicators are: