Class ToOneRelationAdapter

All Implemented Interfaces:
EntityList, Relation, Iterable<Entity>

public class ToOneRelationAdapter extends AbstractRelationAdapter
Maps a to-one hibernate collection to the Relation interface
  • Constructor Details

  • Method Details

    • getInnerInterceptor

      public RelationInterceptor getInnerInterceptor()
      Specified by:
      getInnerInterceptor in class AbstractRelationAdapter
    • setValue

      protected void setValue(@Nullable @Nullable Entity entity)
    • setInverseRelation

      protected void setInverseRelation(@Nullable @Nullable Entity oldValue, @Nullable @Nullable Entity newValue)
    • size

      public int size()
      Description copied from interface: EntityList
      Get the number of entities this list contains.
      Returns:
      The number of entities.
    • get

      @Nullable public @Nullable Entity get()
      Description copied from interface: Relation
      Get the current single target entity of this relation. This method may only be called for relations to a single entity (n-1).
      Specified by:
      get in interface Relation
      Overrides:
      get in class AbstractRelationAdapter
      Returns:
      The current single target entity potentially in unusable state, or null.
    • get

      @Nullable public @Nullable Entity get(int index, boolean eager)
      Description copied from interface: EntityList
      Get the entity at the specified index.
      Parameters:
      index - The index.
      eager - true, if a page should be eagerly loaded, if the entity's state is hollow, false otherwise.
      Returns:
      The entity at the specified index potentially in unusable state, or null.
    • set

      public void set(@Nullable @Nullable Entity entity)
      Description copied from interface: Relation
      Set the relation's entities to the specified single entity. Any other entities will be removed. This method may only be called for relations to a single entity (n-1).

      NOTE: This calls Relation.remove(Entity) and Relation.add(Entity) internally. That's also why the interceptor does not have this.

      Specified by:
      set in interface Relation
      Overrides:
      set in class AbstractRelationAdapter
      Parameters:
      entity - The entity to be set, may be in state conception.
    • set

      public void set(Iterable<Entity> entities)
      Description copied from interface: Relation
      Creates an intersection of the currently linked ones and the given ones, and then calls Relation.remove(Entity) and Relation.add(Entity) in a loop.
      Parameters:
      entities - The list of entities that will be the only linked ones.
    • clear

      public void clear()
      Description copied from interface: Relation
      Removes all entities in this relation. Does the same as calling remove() for all linked entities.