@Documented @Retention(value=RUNTIME) @Target(value=FIELD) public @interface ResultColumn
Annotation that allows for the field of a data class for a given
DataSet to be mapped to a column
of a SQL result set that is returned by invoking a method
decorated by a Select annotation.
ResultColumn annotation is used to decorate a field within
a data class,
allowing the application developer to specify an alternative name for
the column returned in a SQL result set.
The ResultColumn annotation can also be used to indicate that a data class
field is to be used to uniquely identify a row when a DataSet is used in
a disconnected mode.
In the example below, the ResultColumn annotation is used to specify that
the Mammal.weight field corresponds to the column kilos
in the result set that is returned by invoking the method getAllMammals.
public class Mammal {
public String name;
public String description;
public @ResultColumn("kilos") int weight;
}
// Obtain an instance of the Query interface, Queries
Queries myQueries = con.createQueryObject(Queries.class)
DataSet<Mammal> rows = myQueries.getAllMammals();
for( Mammal row :rows) {
System.out.print("name: " + row.name + ", weight: " + row.weight);
}
| Optional Element Summary | |
|---|---|
String |
name
The SQL column to map to. |
boolean |
uniqueIdentifier
Annotation element indicating whether this column is used to uniquely identify a row within a disconnected DataSet. |
String |
value
The SQL column to map to. |
public abstract String name
Note: If the name and the value annotation
element are specified at the same time, a SQLRuntimeException will
be thrown.
String specifying the column's name.public abstract boolean uniqueIdentifier
DataSet. This element is ignored when the DataSet is
used in a connected mode.
true if the field is used to uniquely identify the row; false otherwisepublic abstract String value
Note: If the name and the value annotation
element are specified at the same time, a SQLRuntimeException will
be thrown.
String specifying the column's name.