com.ibm.pdq.annotation

Annotation Type JoinColumn


@Target(value={METHOD,FIELD})


@Retention(value=RUNTIME)


public @interface JoinColumn
For queries against databases, indicates that the annotated property represents a Nested Query Bean. Used only within a @JoinPoint annotation.

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 only within the @JoinPoint annotation.

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 @JoinColumn annotation in which the value of the table element is not "*".

If the resulting Property name within the nested bean does not match the value of the name and table elements then propertyName must be coded.

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
propertyName
Specifies the Property name of the nested bean..
  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

propertyName

public abstract String propertyName
Specifies the Property name of the nested bean.. "*" (the default) indicates that the column label indicated by the name element is also the Property name in the nested bean that will be updated from this column in the ResultSet
Default:
"*"

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 may map columns to properties incorrectly.

Default:
"*"