Class EntityReferenceUtil


  • public class EntityReferenceUtil
    extends java.lang.Object
    EntityReference Utility.
    Since:
    5.0
    • Constructor Detail

      • EntityReferenceUtil

        public EntityReferenceUtil​(DataAccessUnit dataAccessUnit)
        Constructor
        Parameters:
        dataAccessUnit - the associated DataAccessUnit to access entities.
        Since:
        5.13
    • Method Detail

      • getEntityReference

        public static <T extends PersistenceEntityEntityTypeId<T> getEntityReference​(T targetEntity)
        Get the reference to the target entity
        Parameters:
        targetEntity - a referenced entity
        Returns:
        the entity reference that is the entityTypeId of the target entity
      • getEntityWithReferenceTo

        public <T extends EntityReference,​M extends PersistenceEntity> T getEntityWithReferenceTo​(java.lang.Class<T> entityType,
                                                                                                        M targetEntity)
                                                                                                 throws SystemException
        Get the entity of the entity type that has a reference to targetEntity. If there is more than one such entity, return random one of them.
         (returned entity).entityRef = EntityTypeId(targetEntity).
         
        Parameters:
        entityType - the type of entity to return
        targetEntity - a referenced entity
        Returns:
        the entity with a reference to the sourceEntity.
        Throws:
        SystemException - throw if an error occurs.
      • getEntityWithReferenceTo

        public <T extends EntityReference,​M extends PersistenceEntity> T getEntityWithReferenceTo​(java.lang.Class<T> entityType,
                                                                                                        EntityTypeId<M> targetEntityTypeId)
        Get the entity of the entity type that has a reference to targetEntity. If there is more than one such entity, return random one of them.
         (returned entity).entityRef = targetEntityTypeId.
         
        Parameters:
        entityType - the type of entity to return
        targetEntityTypeId - the entityTypeId of target entity
        Returns:
        the entity with a reference to the sourceEntity.
      • getReferencedTargetEntity

        public <T extends EntityReference,​M extends PersistenceEntity> M getReferencedTargetEntity​(T entity)
        Get the target entity referenced by the entity.
         entity.entityRef = EntityTypeId(target entity)
         
        Parameters:
        entity - sourceAware entity
        Returns:
        target entity
      • getReferenceTargetEntity

        public <M extends PersistenceEntity> M getReferenceTargetEntity​(EntityTypeId<M> entityRef)
        Get the entity that the source is referring to.
        Parameters:
        entityRef - entityTypeId of target entity
        Returns:
        target entity