<field> tag

The field tag defines details of a specific field in your database object.  The tag can be to assign an alias to a field.  On DBMS which use sequences instead of identity or auto increment columns the field tag can also be used to specify the sequence to get new value from when writing records into the database.

 

Every field of a database object is used to generate getter and setter methods on record objects.  They're also used in several other places in the framework.  However, many databases have naming conventions for fields (or tables) which don't translate nicely into names for these methods. For example, a column named str_user_name would, by default generate the methods getStr_user_name() and setStr_user_name().

 

Methods with name like these are not just unsightly and hard to type (you try it!), they don't really do a good job of describing what they're returning.  Yes, I know that "Str" probably stands for "string", but would you name a method that adds two numbers and returns the value intAdd()?  Maybe, but more likely you'd name it add().

 

To work around these generated method names you can specify an alias.  For example:

 

<object name="User">
 <field name="str_user_name" alias="username" />
</object>

 

This would configure Reactor to generate methods named getUsername() and setUsername().

Attributes

Attribute

Required

Description

name

Yes

The name of the field in the database.

alias

No

The alias to assign to the field.  If this is not provided it is defaulted to the value of the name attribute.

sequence

No

The name of a sequence to use to get the next value for this field from.  This is useful only for databases which use sequences instead of identity or auto-incrementing values such as Oracle and PosgreSQL.

Child Tags

None

Example

<reactor>
 <objects>
   <object name="User">
     <field name="uid" alias="userId" />
   </object>
 </objects>
</reactor>