Interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>

Type Parameters:
T - Class of the owner of the relation, meaning the start of the directional relation
R - Class of the ownee of the relation, meaning the end of the directional relation
All Known Implementing Classes:
PropertyOne2Many, PropertyOne2One

public interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
Models a directional relation between two classes. The following aspects are tracked.
  • The DAO responsible to handle the instances at the end of the relation.
  • Updates are always handled transitively. All instances referenced directly and indirectly through relations are update each time an instance is updated.
  • The fact if the instances at the end of the relation are exclusively owned and therefore updates and deletions shall be handled transitively. If not they shared are shared between objects and therefore the application is in charge of deletions.
  • Method Summary

    Modifier and Type Method Description
    void delete​(T entity)
    Deletes all the instances at the end of the relation.
    boolean isOwned()
    Returns flag indicating if the instances at the end of the relation are owned or not.
    void retrieve​(T entity, java.lang.Long fid)
    Retrieves all the instances at the end of the relation.
    Dao<R> type()
    Returns the DAO is charge of the objects at the end of the relation.
    void update​(T entity)
    Updates all the instances at the end of the relation.
  • Method Details

    • type

      Dao<R> type()
      Returns the DAO is charge of the objects at the end of the relation. Therefore only typed relations are supported.
      Returns:
      the DAO of the objects at the end of the relation
    • isOwned

      boolean isOwned()
      Returns flag indicating if the instances at the end of the relation are owned or not.
      Returns:
      value of the flag
    • update

      void update​(@NotNull T entity) throws java.security.PrivilegedActionException
      Updates all the instances at the end of the relation.
      Parameters:
      entity - entity owning the relation
      Throws:
      java.security.PrivilegedActionException - if an error occurred when accessing field for foreign key or instance
    • retrieve

      void retrieve​(@NotNull T entity, java.lang.Long fid) throws java.security.PrivilegedActionException
      Retrieves all the instances at the end of the relation.
      Parameters:
      entity - entity owning the relation
      fid - foreign key of the referenced entities. Currently in a N -> 1 relation the fid is the oid of the referenced object, in a 1 -> N the fid is the oid of entity
      Throws:
      java.security.PrivilegedActionException - if an error occurred when accessing field for foreign key or instance
    • delete

      void delete​(@NotNull T entity) throws java.security.PrivilegedActionException
      Deletes all the instances at the end of the relation. Semantically this method performs only if isOwned() returns true.
      Parameters:
      entity - entity owning the relation
      Throws:
      java.security.PrivilegedActionException - if an error occurred when accessing field for foreign key or instance