Package org.fastnate.generator.context
Class EntityClass<E>
java.lang.Object
org.fastnate.generator.context.EntityClass<E>
- Type Parameters:
E- The described class
Describes the DB relevant metadata of an
entity class.- Author:
- Tobias Liefke
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreatePostInsertStatements(E entity, StatementsWriter writer) Marks an entity as written and creates any pending update / insert statements.The type of access that is used for the properties (field access or bean property access).Properties of this entity, excluding theidPropertyor properties fromjoinedParentClass.All properties of this entity, includingidPropertyand properties fromjoinedParentClass.List<List<SingularProperty<E, ?>>> All available sets of properties that make up an additional unique identifier for the entities.All association overriddes of this class and the parent classes.All attribute overriddes of this class and the parent classes.The current context.The SQL expression that is used for the disciminator column of this class.The column fordiscriminator.The represented class.The entity name.getEntityReference(E entity, String idField, boolean whereExpression) Creates an expression that references the id of an entity of this class.The states of written entities.EntityClass<? super E> The description of the entity class that is the root of the current inheritance hierarchy.The property that contains the id for the entity.jakarta.persistence.InheritanceTypeThe inheritance type of this class.EntityClass<? super E> The description of the next entity class that hasInheritanceType.JOINED, if any.Only used duringbuild()to find the joinedParentClass even if that one references our class.The column that contains the id of this entity ifjoinedParentClassis notnull.Mapping from the name of all persistent properties to their description.getTable()The main table of the entity.List<SingularProperty<E, ?>> The properties that make up an additional unique identifier for the entity.Indicates the quality ofuniqueProperties.booleanIndicates that the given entity needs to be written.voidmarkExistingEntity(E entity) Marks a entity reference, where we don't know the ID in the database.<V> voidmarkPendingUpdates(E pendingEntity, V entityToUpdate, Property<V, ?> propertyToUpdate, Object... arguments) Marks an update that is necessary when an entity is written (in the future).Creates a new entity of the representedclass.voidonPropertiesAvailable(Consumer<EntityClass<E>> listener) Registers a listener that is called as soon as all properties of this class are built.toString()
-
Method Details
-
createPostInsertStatements
Marks an entity as written and creates any pending update / insert statements.- Parameters:
entity- the entity that exists now in the databasewriter- the target of the new statements- Throws:
IOException- if the writer throws one
-
getEntityReference
Creates an expression that references the id of an entity of this class.- Parameters:
entity- the entityidField- the field that contains the id, only interesting if the id is anEmbeddedPropertywhereExpression- indicates that the reference is used in a "where" statement- Returns:
- the expression - either by using the
unique propertiesor theidof the entity
-
isNew
Indicates that the given entity needs to be written.- Parameters:
entity- the entity to check- Returns:
trueif the entity was neither written, nor exists in the database
-
markExistingEntity
Marks a entity reference, where we don't know the ID in the database.- Parameters:
entity- the entity to mark
-
markPendingUpdates
public <V> void markPendingUpdates(E pendingEntity, V entityToUpdate, Property<V, ?> propertyToUpdate, Object... arguments) Marks an update that is necessary when an entity is written (in the future).- Parameters:
pendingEntity- the entity that needs to be written, before the update can take placeentityToUpdate- the entity to updatepropertyToUpdate- the property of the entity to updatearguments- additional arguments
-
newInstance
Creates a new entity of the representedclass.- Returns:
- the new entity
-
onPropertiesAvailable
Registers a listener that is called as soon as all properties of this class are built. If the properties are already build, the listener is called immediately.- Parameters:
listener- called as soon as all properties are available
-
toString
-
getContext
The current context. -
getEntityClass
The represented class. -
getEntityName
The entity name. -
getTable
The main table of the entity. -
getAccessStyle
The type of access that is used for the properties (field access or bean property access). -
getInheritanceType
public jakarta.persistence.InheritanceType getInheritanceType()The inheritance type of this class.nullif no subclass is known and no inhertance is indicated (using one of the inheritance annotations). -
getParentEntityClass
Only used duringbuild()to find the joinedParentClass even if that one references our class. -
getJoinedParentClass
The description of the next entity class that hasInheritanceType.JOINED, if any. -
getHierarchyRoot
The description of the entity class that is the root of the current inheritance hierarchy. -
getDiscriminator
The SQL expression that is used for the disciminator column of this class.nullif no discriminator is used -
getDiscriminatorColumn
The column fordiscriminator.nullif this class does not belong to a table that contains a discriminator column -
getPrimaryKeyJoinColumn
The column that contains the id of this entity ifjoinedParentClassis notnull. -
getIdProperty
The property that contains the id for the entity. If ajoinedParentClassexists, this property is the id property of the parent class. -
getUniqueProperties
The properties that make up an additional unique identifier for the entity. Depending onGeneratorContext.getUniquePropertyQuality()andGeneratorContext.getMaxUniqueProperties()this might benull, even if there is a set ofavailable unique properties, if the quality is not enough. -
getUniquePropertiesQuality
Indicates the quality ofuniqueProperties. -
getAllUniqueProperties
All available sets of properties that make up an additional unique identifier for the entities. -
getProperties
Mapping from the name of all persistent properties to their description. -
getAllProperties
All properties of this entity, includingidPropertyand properties fromjoinedParentClass. -
getAdditionalProperties
Properties of this entity, excluding theidPropertyor properties fromjoinedParentClass. -
getEntityStates
The states of written entities. Only interesting for pending updates and if the ID is not generated. -
getAttributeOverrides
All attribute overriddes of this class and the parent classes. -
getAssociationOverrides
All association overriddes of this class and the parent classes.
-