Class EntityLink<E extends Entity>

    • Constructor Detail

      • EntityLink

        protected EntityLink​(E entity)
        The constructor.
        Parameters:
        entity - the target entity.
    • Method Detail

      • isResolved

        public boolean isResolved()
        Returns:
        true if the link target is already resolved, false otherwise (if Link.getTarget() may trigger lazy loading and could also fail if called without an open transaction).
      • getId

        public Id<E> getId()
        Returns:
        the unique identifier of the linked bean. When creating new Entities a link may hold a transient Entity as target that has no ID assigned, yet. In such case this method will return null.
      • getTarget

        public E getTarget()
        Description copied from interface: Link
        This method resolves the linked entity.
        ATTENTION:
        A Link can be evaluated lazily. In such case the first call of this method will resolve the linked entity from the database. That can be a relatively expensive operation and requires an open transaction. Use Link.isResolved() to distinguish and prevent undesired link resolving.
        Further, after serialization (e.g. mapping to JSON and back) maybe only the ID was transferred and this link can not be resolved. In that case this method may return null. Please note that id and target can not both be null. In case a link property is empty it will contain null instead of an empty Link so you can always properly distinguish the scenarios.
        Returns:
        the link target or null if the link can not be resolved.