Type Parameters:
T - the column value type
All Superinterfaces:
Attribute<T>, ColumnCondition.Factory<T>

public interface Column<T> extends Attribute<T>, ColumnCondition.Factory<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 inherit from ColumnCondition.Factory to provide condition creation methods:

public class Store extends DefaultDomain {

    interface Customer {
        EntityType TYPE = DOMAIN.entityType("store.customer");

        // Column definitions
        Column<Integer> ID = TYPE.integerColumn("id");
        Column<String> NAME = TYPE.stringColumn("name");
        Column<String> EMAIL = TYPE.stringColumn("email");
        Column<LocalDate> BIRTH_DATE = TYPE.localDateColumn("birth_date");
        Column<Boolean> ACTIVE = TYPE.booleanColumn("active");
        Column<BigDecimal> CREDIT_LIMIT = TYPE.bigDecimalColumn("credit_limit");
    }

    void defineCustomer() {
        Customer.TYPE.define(
                Customer.ID.define()
                    .primaryKey()
                    .keyGenerator(KeyGenerator.identity()),
                Customer.NAME.define()
                    .column()
                    .nullable(false)
                    .maximumLength(100)
                    .caption("Customer Name"),
                Customer.EMAIL.define()
                    .column()
                    .nullable(false)
                    .maximumLength(255)
                    .caption("Email Address"),
                Customer.BIRTH_DATE.define()
                    .column()
                    .nullable(true)
                    .caption("Date of Birth"),
                Customer.ACTIVE.define()
                    .column()
                    .nullable(false)
                    .defaultValue(true)
                    .caption("Active"),
                Customer.CREDIT_LIMIT.define()
                    .column()
                    .nullable(true)
                    .minimumValue(BigDecimal.ZERO)
                    .maximumValue(new BigDecimal("50000"))
                    .caption("Credit Limit"))
            .build();
    }
}

// Query condition usage (inherited from ColumnCondition.Factory)
List<Entity> activeCustomers = connection.select(
    Customer.ACTIVE.equalTo(true));

List<Entity> customersByName = connection.select(
    Customer.NAME.like("John%"));

List<Entity> recentCustomers = connection.select(
    Customer.BIRTH_DATE.greaterThanOrEqualTo(LocalDate.now().minusYears(25)));

List<Entity> highValueCustomers = connection.select(
    Customer.CREDIT_LIMIT.greaterThan(new BigDecimal("10000")));

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

    • define

      Specified by:
      define in interface Attribute<T>
      Returns:
      a Column.ColumnDefiner for this column
    • 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> valueClass)
      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
      valueClass - the class representing the column value type
      Returns:
      a new Column