Module is.codion.framework.domain
Interface Column<T>
- Type Parameters:
T
- the column value type
- All Superinterfaces:
Attribute<T>
,ColumnConditionFactory<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 ColumnConditionFactory
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)
.minimum(BigDecimal.ZERO)
.maximum(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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
ProvidesColumnDefinition.Builder
instances.static interface
Converts to and from SQL values, such as integers being used to represent booleans in a database.static interface
Gets a single value from aResultSet
.static interface
Sets a parameter value in aPreparedStatement
Nested classes/interfaces inherited from interface is.codion.framework.domain.entity.attribute.Attribute
Attribute.AttributeDefiner<T>, Attribute.Type<T>
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Column
<T> column
(EntityType entityType, String name, TypeReference<T> typeReference) Creates a newColumn
, associated with the given entityType.static <T> Column
<T> column
(EntityType entityType, String name, Class<T> valueClass) Creates a newColumn
, associated with the given entityType.define()
Methods inherited from interface is.codion.framework.domain.entity.attribute.Attribute
entityType, name, type
Methods inherited from interface is.codion.framework.domain.entity.condition.ColumnConditionFactory
between, betweenExclusive, equalTo, equalToIgnoreCase, equalToIgnoreCase, greaterThan, greaterThanOrEqualTo, in, in, inIgnoreCase, inIgnoreCase, isNotNull, isNull, lessThan, lessThanOrEqualTo, like, likeIgnoreCase, notBetween, notBetweenExclusive, notEqualTo, notEqualToIgnoreCase, notEqualToIgnoreCase, notIn, notIn, notInIgnoreCase, notInIgnoreCase, notLike, notLikeIgnoreCase
-
Method Details
-
define
Column.ColumnDefiner<T> define()- Specified by:
define
in interfaceAttribute<T>
- Returns:
- a
Column.ColumnDefiner
for this column
-
column
Creates a newColumn
, associated with the given entityType.- Type Parameters:
T
- the column type- Parameters:
entityType
- the entityType owning this columnname
- the column nametypeReference
- theTypeReference
representing the column value type- Returns:
- a new
Column
-
column
Creates a newColumn
, associated with the given entityType.- Type Parameters:
T
- the column type- Parameters:
entityType
- the entityType owning this columnname
- the column namevalueClass
- the class representing the column value type- Returns:
- a new
Column
-