|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
@Target(value={FIELD,METHOD}) @Retention(value=RUNTIME) public @interface ResultColumn
By default columns for ResultSet
are mapped directly to public
fields within the data object class. The ResultColumn
annotation
allows you to change the way the column is mapped.
public class User {
public String username;
@ResultColumn("birth_date")
public Date birthDate;
}
Instead of looking for a column named "birthDate"
in the
ResultSet
, the mapping code will now look for a column
named "birth_date"
and map it to the "birthDate"
variable.
@ResultColumn
can also map columns to setter methods. The
method does not have to follow any naming convention, but accept only
a single, simple parameter type (which is the type the column is expected
to be).
public class User {
private String name;
...
@ResultColumn("username")
public void setUsername(String name) {
this.name = name;
}
}
The above code will attempt to map a column named "username" to
the data object, by invoking the "setUsername" method. This
mapping totally ignored the name of the method, and it's parameters.
Note that if a method annotated by @ResultColumn
takes more
than one parameter, an IllegalArgumentException
will
be thrown during validation by the QueryTool
.
Note: All column names in EoD SQL are treated as case in-sensitive, since different JDBC drivers respond with different meta-data.
Required Element Summary | |
---|---|
String |
value
The name of the field as it will appear in the ResultSet
meta-data. |
Element Detail |
---|
public abstract String value
ResultSet
meta-data. If no ResultColumn
is found annotating a public field,
it is assumed that the field will be mapped on it's variable-name.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |