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
)Constructor and Description |
---|
PrimitiveProperty(GeneratorContext context,
String table,
AttributeAccessor attribute,
javax.persistence.Column columnMetadata)
Instantiates a new primitive property.
|
Modifier and Type | Method and Description |
---|---|
void |
addInsertExpression(E entity,
InsertStatement statement)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
static <T,E extends Enum<E>> |
createConverter(AttributeAccessor attribute,
Class<T> targetType,
boolean mapKey)
Creates a converter for a primitive type.
|
protected String |
getDefaultValue(AttributeAccessor attribute)
Finds the default value from the given attribute.
|
protected GeneratorDialect |
getDialect()
Resolves the current dialect from the context.
|
String |
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.
|
getColumn, isTableColumn
createPostInsertStatements, createPreInsertStatements, failIfRequired, findReferencedEntities, generatePendingStatements, getName, getValue, isRequired, setValue, toString
public PrimitiveProperty(GeneratorContext context, String 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 static <T,E extends Enum<E>> ValueConverter<T> createConverter(AttributeAccessor attribute, Class<T> targetType, boolean mapKey)
T
- the generic typeE
- the element typeattribute
- the accessor for the attribute that contains the value, not nessecarily of the target typetargetType
- the primitive typemapKey
- indicates that the converter is for the key of a mapUnsupportedTypeConverter
if no converter is availablepublic void addInsertExpression(E entity, InsertStatement statement)
Property
addInsertExpression
in class Property<E,T>
entity
- the inspected entitystatement
- the created statementprotected String getDefaultValue(AttributeAccessor attribute)
attribute
- the current attribute of the propertynull
if none is setDefaultValue.value()
protected GeneratorDialect getDialect()
public String 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 availableCopyright © 2016 fastnate.org. All rights reserved.