primaryKeyIndex
int primaryKeyIndex()
- Returns:
- this columns zero based index in the primary key, -1 if this column is not part of a primary key
T
- the underlying typeAttributeDefinition<T>
AuditColumnDefinition<T>
ColumnDefinition extends AttributeDefinition
with column-specific configuration
such as primary key properties, SQL expressions, insertable/updatable flags, and
database value conversion logic.
Column definitions are created through the column builder API:
interface Product {
EntityType TYPE = DOMAIN.entityType("store.product");
Column<Integer> ID = TYPE.integerColumn("id");
Column<String> NAME = TYPE.stringColumn("name");
Column<BigDecimal> PRICE = TYPE.bigDecimalColumn("price");
Column<Boolean> ACTIVE = TYPE.booleanColumn("active");
Column<LocalDateTime> CREATED_DATE = TYPE.localDateTimeColumn("created_date");
}
Product.TYPE.define(
// Primary key with auto-generation
Product.ID.define()
.primaryKey()
.keyGenerator(KeyGenerator.identity()),
// Required string column with length constraint
Product.NAME.define()
.column()
.nullable(false)
.maximumLength(100),
// Decimal column with precision and range validation
Product.PRICE.define()
.column()
.nullable(false)
.minimumValue(BigDecimal.ZERO)
.maximumValue(new BigDecimal("99999.99"))
.maximumFractionDigits(2),
// Boolean column with database mapping
Product.ACTIVE.define()
.booleanColumn(String.class, "Y", "N") // Maps Y/N to true/false
.defaultValue(true),
// Audit column (database-managed)
Product.CREATED_DATE.define()
.column()
.insertable(false) // Not included in INSERT
.updatable(false) // Not included in UPDATE
.columnHasDefaultValue(true)) // Database provides value
.build();
static interface
ColumnDefinition.Builder<T,B extends ColumnDefinition.Builder<T,B>>
ColumnDefinition
AttributeDefinition.ValueSupplier<T>
DATE_FORMAT, DATE_TIME_FORMAT, DECIMAL_ROUNDING_MODE, DECIMAL_SEPARATOR, DEFAULT_MAXIMUM_FRACTION_DIGITS, GROUPING_SEPARATOR, MAXIMUM_FRACTION_DIGITS, MNEMONIC_RESOURCE_SUFFIX, NUMBER_FORMAT_GROUPING, TIME_FORMAT, TRIM_STRINGS, USE_LEXICAL_STRING_COMPARATOR
boolean
Attribute
this definition is based on, should be unique within an Entity.boolean
<C> Column.Converter<C,T>
ResultSet
boolean
groupBy()
boolean
name()
boolean
int
boolean
readOnly()
boolean
boolean
selected()
void
set(PreparedStatement statement,
int index,
@Nullable T value)
PreparedStatement
int
type()
boolean
caption, comparator, dateTimeFormatter, dateTimePattern, decimalRoundingMode, defaultValue, derived, description, entityType, format, hasDefaultValue, hidden, items, maximumFractionDigits, maximumLength, maximumValue, minimumValue, mnemonic, nullable, string, trim, validItem
AttributeDefinition
Attribute
this definition is based on, should be unique within an Entity.
By default, the Attribute.name()
serves as column name for database columns.attribute
in interface AttributeDefinition<T>
Types
.C
- the colum value typeColumn.Converter
for this column.ResultSet
resultSet
- the ResultSet
index
- this columns index in the resultResultSet
SQLException
- in case of an exceptionPreparedStatement
statement
- the statementindex
- the parameter indexvalue
- the value to set, may be nullSQLException
- in case of an exception