Annotation Interface DatabaseColumn


Allows specification of alternate column names for resultset mapping.

Useful in situations where column names are ugly, inconsistent, or do not map well to camel-case Java property names. Aliases are additive to the standard name candidates.

On a JavaBean, the annotated instance field must identify exactly one writable property exposed by a public instance setter. Matching includes JavaBeans capitalization and primitive-boolean fields such as isActive with setActive(boolean). The mapper invokes the setter rather than writing the field. An unmatched, ambiguous or static annotated bean field is a mapping-metadata error, even if that field's aliases are absent from the selected columns. Record-component annotations do not require setters.

For example:

public class Example {
  @DatabaseColumn({ "systok", "sys_tok" })
  private UUID systemToken;

  public UUID getSystemToken() {
    return systemToken;
  }

  public void setSystemToken(UUID systemToken) {
    this.systemToken = systemToken;
  }
}

database.query("SELECT systok FROM example").fetchObject(Example.class);
Since:
1.0.0
Author:
Mark Allen
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description