public interface class java.sql
ResultColumn


Hide details Login
Java SE 6
  
Implements: Annotation
@Documented
@Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME)
@Target(value=java.lang.annotation.ElementType.FIELD)

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.

Overview

The 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. 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);
 }
 
since1.6

Optional Elements
abstract public String name()
The SQL column to map to.

Note: If the name and the value annotation element are specified at the same time, a SQLRuntimeException will be thrown.
returna String specifying the column's name.
since1.6

abstract public boolean uniqueIdentifier()
Annotation element indicating whether this column is used to uniquely identify a row within a disconnected DataSet. This element is ignored when the DataSet is used in a connected mode.
returna true if the field is used to uniquely identify the row; false otherwise
since1.6
abstract public String value()
The SQL column to map to.

Note: If the name and the value annotation element are specified at the same time, a SQLRuntimeException will be thrown.
returna String specifying the column's name.
since1.6