Class EntityInstance<T>
- java.lang.Object
-
- net.lecousin.reactive.data.relational.model.metadata.EntityInstance<T>
-
- Type Parameters:
T- type of entity
public class EntityInstance<T> extends Object
Entity instance with state and metadata.- Author:
- Guillaume Le Cousin
-
-
Constructor Summary
Constructors Constructor Description EntityInstance(T instance, EntityState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.springframework.data.relational.core.sql.ConditiongetConditionOnId(SqlQuery<?> query)CriteriagetCriteriaOnId(String entityName)ObjectgetDatabaseValue(String propertyName)Returns the value stored in database for the given property.ObjectgetDatabaseValue(PropertyMetadata property)Returns the value stored in database for the given property.TgetEntity()ObjectgetForeignKeyValue(PropertyMetadata fkProperty, Object foreignInstance)Return the primary key from a foreign key instance.ObjectgetId()Returns an object representing the unique id of the entity: If the entity has an @Id property it returns its value If the entity has a @CompositeId it returns aCompositeIdValueElse it returns aCompositeIdValuewith all persisted propertiesObjectgetIdPropertyValue()Return the value of the @Id property, or null.EntityMetadatagetMetadata()org.springframework.data.mapping.PersistentPropertyAccessor<T>getPropertyAccessor()ObjectgetRequiredPrimaryKey()Return the primary key.EntityStategetState()Class<?>getType()ObjectgetValue(PropertyMetadata property)booleanisPersistedForeignKey(PropertyMetadata fkProperty, Object foreignInstance)Return true if the persisted foreign id is equals to the id of the foreignInstance (or both null).voidsetValue(PropertyMetadata property, Object value)
-
-
-
Constructor Detail
-
EntityInstance
public EntityInstance(@NonNull T instance, @NonNull EntityState state)
-
-
Method Detail
-
getEntity
@NonNull public T getEntity()
-
getState
@NonNull public EntityState getState()
-
getPropertyAccessor
@NonNull public org.springframework.data.mapping.PersistentPropertyAccessor<T> getPropertyAccessor()
-
getType
@NonNull public Class<?> getType()
-
getMetadata
@NonNull public EntityMetadata getMetadata()
-
getValue
public Object getValue(PropertyMetadata property)
-
getDatabaseValue
public Object getDatabaseValue(String propertyName)
Returns the value stored in database for the given property.
-
getDatabaseValue
public Object getDatabaseValue(PropertyMetadata property)
Returns the value stored in database for the given property.
-
setValue
public void setValue(PropertyMetadata property, Object value)
-
getId
@Nullable public Object getId()
Returns an object representing the unique id of the entity:- If the entity has an @Id property it returns its value
- If the entity has a @CompositeId it returns a
CompositeIdValue - Else it returns a
CompositeIdValuewith all persisted properties
-
getIdPropertyValue
@Nullable public Object getIdPropertyValue()
Return the value of the @Id property, or null.
-
getRequiredPrimaryKey
@NonNull public Object getRequiredPrimaryKey()
Return the primary key.
-
isPersistedForeignKey
public boolean isPersistedForeignKey(PropertyMetadata fkProperty, Object foreignInstance)
Return true if the persisted foreign id is equals to the id of the foreignInstance (or both null).
-
getForeignKeyValue
public Object getForeignKeyValue(PropertyMetadata fkProperty, Object foreignInstance)
Return the primary key from a foreign key instance.
-
getConditionOnId
public org.springframework.data.relational.core.sql.Condition getConditionOnId(SqlQuery<?> query)
-
-