Reactor field tag
I have noticed that not a lot of people either disregard or do not really know what the field tag is used for. Most of the information below is from the live docs so be sure to review the documentation by clicking on the link below. The field tag is used inside of an &ls;object> definition and is used to define the details of a specific field in your database object. The field tag has three attributes name, alias, and sequence. The name attribute is required and it is the name of the field in the database. The field tag is used to assign an alias to a field, if it is not provided the name of the database field is used. Finally the sequence attribute is not required. On a database that uses 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. Let’s go ahead and look at an example of where we would use the field tag. First is the sql script that generates the database table.
[userId] [int] NOT NULL ,
[str_first_name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[str_last_name] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[str_username] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[str_password] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
Now let’s look at why we use the field tag. You will notice that this table we are working with has some hard to work with column names. If you want throughout your code you could use your getters and setters typing those names every time but their really is an easier way to do it. Would you rather type getStr_first_name() or getFirstName(). The latter looks a lot easier to me, how about you? This is where the almighty alias attribute comes into play.
<field name="str_first_name" alias="FirstName"/>
<field name="str_last_name" alias="LastName"/>
<field name="str_username" alias="Username"/>
<field name="str_password" alias="Password"/>
</object>
