com.ibm.pdq.annotation

Annotation Type Column


@Target(value={METHOD,FIELD})

  • @Retention(value=RUNTIME)
  • public @interface Column
    For queries against databases, indicates that the annotated property represents the described column.

    When populating a pureQuery bean with the contents of a query result row, pureQuery attempts to match the column label found in the query results (as indicated by ResultSetMetaData.getColumnLabel(int)) with the properties in the pureQuery bean. By default, pureQuery assumes that a property represents a column with a label that matches (without respect to case) the property name. pureQuery assumes that the SQL query result only contains one column with that name. When this mapping is correct, no further notation of the column mapping is required. When a property name does not match (without respect to case) the represented column, or when a column name appears more than once in a query result, this annotation can be used to indicate which column the property represents.

    This annotation can be used on fields and accessor methods for properties when the fields and methods are public. pureQuery ignores the @Column annotation everywhere else.

    See the pureQuery Runtime documentation for a description of how property names are determined.

    If a query result contains multiple columns with the same label, pureQuery cannot correctly map the columns to properties unless each property that represents a column with a duplicated label has a @Column annotation in which the value of the table element is not "*".

    The column mapping is also undefined if a query result contains two columns that have identical labels and identical table names. If this occurs, aliases should be provided in the SQL statement (for example, by using the "AS" clause) to change the label of at least one of the columns.


    Required Element Summary

    Modifier and Type Required Element and Description
    1. String
    name
    Specifies the label of the database column that the property represents.

    Optional Element Summary

    Modifier and Type Optional Element and Description
    1. String
    table
    Specifies the name of the database table of the column represented by the annotated property.

    Required Element Detail

    name

    public abstract String name
    
    Specifies the label of the database column that the property represents.

    The label of a column is the value returned by ResultSetMetaData.getColumnLabel(int). It is the name of the column, unless the SQL statement specifies an alias for the column (for example, by using the "AS" clause), in which case it is the alias.

    Optional Element Detail

    table

    public abstract String table
    
    Specifies the name of the database table of the column represented by the annotated property. "*" indicates that the column label indicated by the name element appears only once in the query result, and that the annotated property represents that column, regardless of which table it is in.

    If this element is either not provided, or if it is provided with a value of "*", and the query result contains more than one column with the label indicated by the name element, then pureQuery cannot map columns to properties.

    If the class has a table annotation then the default table name is the table name defined, code table = "" to indicate no table name.

    Default:
    "*"