Interface Column<T>

Type Parameters:
T - the column value type
All Superinterfaces:
Attribute<T>, ColumnConditions<T>

public sealed interface Column<T> extends Attribute<T>, ColumnConditions<T>
An Attribute representing a table column.

Columns are attributes that map directly to database table columns, providing type-safe access to column values and enabling query condition creation. They extend the base Attribute interface with column-specific functionality for database operations.

Columns are declared in the domain API, and defined in the domain model:

interface Track {
  EntityType TYPE = DOMAIN.entityType("chinook.track");

  // Column definitions
  Column<Long> ID = TYPE.longColumn("id");
  Column<String> NAME = TYPE.stringColumn("name");
  Column<String> COMPOSER = TYPE.stringColumn("composer");
  Column<Integer> MILLISECONDS = TYPE.integerColumn("milliseconds");
  Column<Integer> RATING = TYPE.integerColumn("rating");
  Column<BigDecimal> UNITPRICE = TYPE.bigDecimalColumn("unitprice");
}

EntityDefinition track() {
  return Track.TYPE.as()
          .attributes(
                  Track.ID.as()
                          .primaryKey()
                          .generator(Generator.identity()),
                  Track.NAME.as()
                          .column()
                          .caption("Name")
                          .nullable(false)
                          .maximumLength(200),
                  Track.COMPOSER.as()
                          .column()
                          .caption("Composer")
                          .maximumLength(220),
                  Track.MILLISECONDS.as()
                          .column()
                          .caption("Duration")
                          .nullable(false),
                  Track.RATING.as()
                          .column()
                          .caption("Rating")
                          .nullable(false)
                          .defaultValue(5)
                          .range(1, 10),
                  Track.UNITPRICE.as()
                          .column()
                          .caption("Price")
                          .nullable(false)
                          .minimum(0)
                          .fractionDigits(2))
          .build();
}

Columns inherit from ColumnConditions to provide condition creation methods:

// Query condition usage (inherited from ColumnConditions)
List<Entity> bachTracks = connection.select(
        Track.COMPOSER.equalTo("Johann Sebastian Bach"));

List<Entity> loveSongs = connection.select(
        Track.NAME.likeIgnoreCase("%love%"));

List<Entity> longTracks = connection.select(
        Track.MILLISECONDS.greaterThanOrEqualTo(600_000));

List<Entity> expensiveTracks = connection.select(
        Track.UNITPRICE.greaterThan(BigDecimal.valueOf(0.99)));

// Complex conditions
List<Entity> liveAlbums = connection.select(and(
        Album.ARTIST_FK.in(artists),
        Album.TITLE.likeIgnoreCase("%live%")));
See Also: