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:
  • Method Details

    • as

      Specified by:
      as in interface Attribute<T>
      Returns:
      a Column.ColumnDefiner for this column
    • as

      Returns a ColumnDefinition.Builder for this column, configured by the given template.
      Customer.LASTNAME.as(REQUIRED_SEARCHABLE)
      				.maximumLength(20);

      The template is applied first, any subsequent configuration overriding it.

      Note that a column has Attribute.as(AttributeTemplate) as well, so the template must be typed, an inline lambda being ambiguous between the two.

      Parameters:
      template - the column template
      Returns:
      a ColumnDefinition.Builder configured by the given template
    • column

      static <T> Column<T> column(EntityType entityType, String name, TypeReference<T> typeReference)
      Creates a new Column, associated with the given entityType.
      Type Parameters:
      T - the column type
      Parameters:
      entityType - the entityType owning this column
      name - the column name
      typeReference - the TypeReference representing the column value type
      Returns:
      a new Column
    • column

      static <T> Column<T> column(EntityType entityType, String name, Class<T> type)
      Creates a new Column, associated with the given entityType.
      Type Parameters:
      T - the column type
      Parameters:
      entityType - the entityType owning this column
      name - the column name
      type - the class representing the column value type
      Returns:
      a new Column