@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.
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.
There must be at least one column specified to uniquely identify a row for a disconnected DataSet otherwise a SQLRuntimeException will be thrown.
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.
public abstract boolean uniqueIdentifier
public abstract String value
Note : If the name and the value annotation element are specified at the same time, a SQLRuntimeException will be thrown.