E
- The type of the container classT
- The type of the primitivepublic class PrimitiveProperty<E,T> extends SingularProperty<E,T>
EntityClass
.
A primitive property is not only a Java primitive, but it includes all properties that are of a type that is easily
mapped to an SQL expression using a ValueConverter
.
This includes:
Boolean
, Character
, Byte
, Short
, Integer
,
Long
, Float
, Double
)String
BigInteger
and BigDecimal
Date
and its subclasses (Date
, Time
and Timestamp
)
Calendar
byte[]
and Byte[]
)char[]
and Character[]
)Enum
)Modifier and Type | Field and Description |
---|---|
private GeneratorColumn |
column
The column name in the table.
|
private GeneratorContext |
context
The current context.
|
private ValueConverter<T> |
converter
The converter for any value.
|
private String |
defaultValue
The default value.
|
private boolean |
required
Indicates if the property required.
|
private GeneratorTable |
table
The table of the column.
|
Constructor and Description |
---|
PrimitiveProperty(GeneratorContext context,
GeneratorTable table,
AttributeAccessor attribute,
javax.persistence.Column columnMetadata)
Instantiates a new primitive property.
|
PrimitiveProperty(GeneratorContext context,
GeneratorTable table,
AttributeAccessor attribute,
javax.persistence.Column columnMetadata,
boolean autogenerated)
Instantiates a new primitive property.
|
Modifier and Type | Method and Description |
---|---|
void |
addInsertExpression(TableStatement statement,
E entity)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
GeneratorColumn |
getColumn()
The column name in the table.
|
GeneratorContext |
getContext()
The current context.
|
ValueConverter<T> |
getConverter()
The converter for any value.
|
String |
getDefaultValue()
The default value.
|
protected String |
getDefaultValue(AttributeAccessor attribute)
Finds the default value from the given attribute.
|
protected GeneratorDialect |
getDialect()
Resolves the current dialect from the context.
|
ColumnExpression |
getExpression(E entity,
boolean whereExpression)
Creates the expression for the current value of the given entity in SQL.
|
String |
getPredicate(E entity)
Creates an SQL predicate that references all entities that have the same value as the given entity.
|
GeneratorTable |
getTable()
The table of the column.
|
boolean |
isRequired()
Indicates if the property required.
|
private static boolean |
isRequired(AttributeAccessor attribute) |
isTableColumn
createPostInsertStatements, createPreInsertStatements, failIfRequired, findReferencedEntities, generatePendingStatements, getAttribute, getName, getType, getValue, isComposition, setValue, toString
private final GeneratorContext context
private final GeneratorTable table
private final GeneratorColumn column
private final boolean required
private final ValueConverter<T> converter
private final String defaultValue
public PrimitiveProperty(GeneratorContext context, GeneratorTable table, AttributeAccessor attribute, javax.persistence.Column columnMetadata)
context
- the current contexttable
- the table that the column belongs toattribute
- the attribute of the propertycolumnMetadata
- the column metadatapublic PrimitiveProperty(GeneratorContext context, GeneratorTable table, AttributeAccessor attribute, javax.persistence.Column columnMetadata, boolean autogenerated)
context
- the current contexttable
- the table that the column belongs toattribute
- the attribute of the propertycolumnMetadata
- the column metadataautogenerated
- true
if the values of this property are not part of any insert statement because they are
generated by the databaseprivate static boolean isRequired(AttributeAccessor attribute)
public void addInsertExpression(TableStatement statement, E entity)
Property
addInsertExpression
in class Property<E,T>
statement
- the created statemententity
- the inspected entityprotected String getDefaultValue(AttributeAccessor attribute)
attribute
- the current attribute of the propertynull
if none is setDefaultValue.value()
protected GeneratorDialect getDialect()
public ColumnExpression getExpression(E entity, boolean whereExpression)
Property
getExpression
in class Property<E,T>
entity
- the entitywhereExpression
- indicates that the expression is used in a "where" statementnull
if no existspublic String getPredicate(E entity)
Property
getPredicate
in class Property<E,T>
entity
- the entitynull
if no such expression is available@Generated(value="lombok") public GeneratorContext getContext()
@Generated(value="lombok") public GeneratorTable getTable()
@Generated(value="lombok") public GeneratorColumn getColumn()
getColumn
in class SingularProperty<E,T>
@Generated(value="lombok") public boolean isRequired()
isRequired
in class Property<E,T>
true
if the field is required@Generated(value="lombok") public ValueConverter<T> getConverter()
@Generated(value="lombok") public String getDefaultValue()
Copyright © 2022 fastnate.org. All rights reserved.