E
- The type of the container classpublic class GeneratedIdProperty<E> extends PrimitiveProperty<E,Number>
Id
property of an EntityClass
.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(E entity,
InsertStatement statement)
Adds an expression according to the current value of the property for the given entity to an SQL insert
statement.
|
List<? extends EntityStatement> |
createPreInsertStatements(E entity)
Creates SQL statements that are necessary before this property is written (e.g. for updating the table
generator).
|
String |
getExpression(E entity,
boolean whereExpression)
Creates the reference of an entity in SQL using its (relative or absolute) id.
|
boolean |
isNew(E entity)
Indicates that the given entity needs to be written.
|
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,
long 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.
|
createConverter, getDefaultValue, getDialect, getPredicate
getColumn, isTableColumn
createPostInsertStatements, failIfRequired, findReferencedEntities, generatePendingStatements, getName, getValue, isRequired, setValue, toString
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(E entity, InsertStatement statement)
Property
addInsertExpression
in class PrimitiveProperty<E,Number>
entity
- the inspected entitystatement
- the created statementpublic List<? extends EntityStatement> createPreInsertStatements(E entity)
Property
createPreInsertStatements
in class Property<E,Number>
entity
- the inspected entitypublic String getExpression(E entity, boolean whereExpression)
getExpression
in class PrimitiveProperty<E,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, long id)
entity
- the entity to markid
- the id of the entity in the databasepublic void postInsert(E entity)
entity
- the current entityCopyright © 2016 fastnate.org. All rights reserved.