This annotation can be applied to fields or methods in an entity class.
Attributes:
- `value`: Specifies the name of the column this field or method maps to in the database.
- `joinOn`: Indicates the condition used when performing a join operation on another table.
- `joinUsing`: Specifies whether the join should use the field's value as part of a "using" clause.
- `generator`: References a custom ColumnValueGenerator implementation to dynamically compute or fetch the column value.
- `generateUsingSequence`: Specifies the name of a database sequence to use for generating the column value.
Example Use Cases: - Static column mapping using the `value` attribute for straightforward entity-table mapping. - Dynamic column value generation through the `generator` attribute. - Sequence-based value generation for primary key fields using the `generateUsingSequence` attribute.
Note: - The `ColumnValueGenerator` referenced in the `generator` attribute provides a functional interface for computing the column's value at runtime using metadata information. - A blank or default value for an attribute signals that the feature is not applicable or disabled.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the database sequence to be used for generating values for the annotated field or method.Class<? extends ColumnValueGenerator> Specifies a custom implementation ofColumnValueGeneratorto dynamically generate or compute values for the database column during runtime.Specifies the join condition used when performing a join operation on another table.booleanIndicates whether the mapping should use the field's value as part of a "using" clause when performing a SQL join operation.
-
Element Details
-
value
String valueSpecifies the name of the database column that the annotated field or method maps to. This value is used for static column mapping in the Litebridge ORM.- Returns:
- The name of the column in the database table.
-
joinOn
String joinOnSpecifies the join condition used when performing a join operation on another table. This attribute allows for defining custom SQL conditions to establish the relationship between the current column and a column in another table.- Returns:
- The join condition as a string. If left empty or not specified, no join condition is associated with this column.
- Default:
""
-
joinUsing
boolean joinUsingIndicates whether the mapping should use the field's value as part of a "using" clause when performing a SQL join operation. This is typically applied in cases where the field represents a foreign key that should be included in the "USING" syntax for join conditions.- Returns:
- true if the "using" clause should be applied; false otherwise.
- Default:
false
-
generator
Class<? extends ColumnValueGenerator> generatorSpecifies a custom implementation ofColumnValueGeneratorto dynamically generate or compute values for the database column during runtime. This attribute allows for overriding the default behavior of static column value assignment by providing a generator class that implements the logic for value computation.- Returns:
- A class that extends
ColumnValueGenerator, which will be used to generate the column value. If not specified, the default isColumnValueGenerator.class, indicating no custom generator is used. The class must have a no-argument constructor.
- Default:
org.litebridgedb.db.spi.generator.ColumnValueGenerator.class
-
generateUsingSequence
String generateUsingSequenceSpecifies the database sequence to be used for generating values for the annotated field or method. When provided, this sequence will be used to automatically populate the column value during insert operations.- Returns:
- The name of the database sequence to use. If not specified, no sequence will be used.
- Default:
""
-