Class 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 Detail

      • EntityInstance

        public EntityInstance​(@NonNull
                              T instance,
                              @NonNull
                              EntityState state)
    • Method Detail

      • getEntity

        @NonNull
        public T getEntity()
      • getPropertyAccessor

        @NonNull
        public org.springframework.data.mapping.PersistentPropertyAccessor<T> getPropertyAccessor()
      • getType

        @NonNull
        public Class<?> getType()
      • 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.
      • 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 CompositeIdValue with 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.
      • getCriteriaOnId

        public Criteria getCriteriaOnId​(String entityName)
      • getConditionOnId

        public org.springframework.data.relational.core.sql.Condition getConditionOnId​(SqlQuery<?> query)