E
- The type of the container classT
- The type of the propertypublic class GeneratedIdProperty<E,T extends Number> extends PrimitiveProperty<E,T>
Id
property of an EntityClass
.Modifier and Type | Field and Description |
---|---|
private boolean |
absoluteIds
Shortcut for the inverse of
GeneratorContext.isWriteRelativeIds() . |
private EntityClass<E> |
entityClass
The entity class that contains our property.
|
private IdGenerator |
generator
The generator used for generating new values of this property.
|
private boolean |
primitive
Indicates that the ID is never "null", because we have a primitive ID value.
|
private Class<T> |
type
The type of the numbers.
|
private T |
unknownIdMarker
Marker for the ID of an entity which needs to be referenced by its unique properties.
|
Constructor and Description |
---|
GeneratedIdProperty(EntityClass<E> entityClass,
AttributeAccessor attribute,
javax.persistence.Column column)
Creates a new instance of
GeneratedIdProperty . |
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.
|
void |
createPreInsertStatements(StatementsWriter writer,
E entity)
Creates SQL statements that are necessary before this property is written (e.g. for updating the table
generator).
|
private void |
ensureIsNew(E entity) |
EntityClass<E> |
getEntityClass()
The entity class that contains our property.
|
ColumnExpression |
getExpression(E entity,
boolean whereExpression)
Creates the reference of an entity in SQL using its (relative or absolute) id.
|
IdGenerator |
getGenerator()
The generator used for generating new values of this property.
|
Class<T> |
getType()
The type of the numbers.
|
T |
getUnknownIdMarker()
Marker for the ID of an entity which needs to be referenced by its unique properties.
|
boolean |
isAbsoluteIds()
Shortcut for the inverse of
GeneratorContext.isWriteRelativeIds() . |
boolean |
isNew(E entity)
Indicates that the given entity needs to be written.
|
boolean |
isPrimitive()
Indicates that the ID is never "null", because we have a primitive ID value.
|
boolean |
isReference(E entity)
Indicates that the given entity was not written before, but exists already in the database.
|
void |
markReference(E entity)
Marks an entity as reference, where we don't know the ID database.
|
void |
markReference(E entity,
T id)
Marks an entity as reference, where we know the id in the database.
|
void |
postInsert(E entity)
Called after the insert statement was written, to update any nessecary state in the context.
|
getColumn, getContext, getConverter, getDefaultValue, getDefaultValue, getDialect, getPredicate, getTable, isRequired
isTableColumn
createPostInsertStatements, failIfRequired, findReferencedEntities, generatePendingStatements, getAttribute, getName, getValue, isComposition, setValue, toString
private final boolean absoluteIds
GeneratorContext.isWriteRelativeIds()
.private final boolean primitive
private final EntityClass<E> entityClass
private final T extends Number unknownIdMarker
private final IdGenerator generator
public GeneratedIdProperty(EntityClass<E> entityClass, AttributeAccessor attribute, javax.persistence.Column column)
GeneratedIdProperty
.entityClass
- the entity classattribute
- the accessor of the id attributecolumn
- the column annotationpublic void addInsertExpression(TableStatement statement, E entity)
Property
addInsertExpression
in class PrimitiveProperty<E,T extends Number>
statement
- the created statemententity
- the inspected entitypublic void createPreInsertStatements(StatementsWriter writer, E entity) throws IOException
Property
createPreInsertStatements
in class Property<E,T extends Number>
writer
- the target of the created statementsentity
- the inspected entityIOException
- if the writer throws an exceptionprivate void ensureIsNew(E entity)
public ColumnExpression getExpression(E entity, boolean whereExpression)
getExpression
in class PrimitiveProperty<E,T extends Number>
entity
- the entitywhereExpression
- indicates that the reference is used in a "where" statementnull
if the entity was not written up to nowIllegalArgumentException
- if the entity is a reference
without any idpublic boolean isNew(E entity)
entity
- the entity to checktrue
if the id of the given entity is not set up to nowpublic boolean isReference(E entity)
entity
- the entity to checktrue
if the entity was marked as reference
public void markReference(E entity)
entity
- the entity to markpublic void markReference(E entity, T id)
entity
- the entity to markid
- the id of the entity in the databasepublic void postInsert(E entity)
entity
- the current entity@Generated(value="lombok") public boolean isAbsoluteIds()
GeneratorContext.isWriteRelativeIds()
.@Generated(value="lombok") public boolean isPrimitive()
@Generated(value="lombok") public EntityClass<E> getEntityClass()
@Generated(value="lombok") public Class<T> getType()
@Generated(value="lombok") public T getUnknownIdMarker()
@Generated(value="lombok") public IdGenerator getGenerator()
Copyright © 2022 fastnate.org. All rights reserved.