Class PropertyOne2One<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>

java.lang.Object
net.tangly.orm.imp.PropertySimple<T>
net.tangly.orm.imp.PropertyOne2One<T,​R>
Type Parameters:
T - class owning the property
R - Class referenced by the property
All Implemented Interfaces:
Property<T>, Relation<T,​R>

public class PropertyOne2One<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
extends PropertySimple<T>
implements Relation<T,​R>
Models a property with at most one managed instance of a target entity. The following rules apply
  • The name of the property identifies the field in the instance owning the property.
  • THe name of the property is a column in the owning entity table with a BIGINT sql type.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.tangly.orm.Property

    Property.ConverterType
  • Field Summary

    Fields inherited from class net.tangly.orm.imp.PropertySimple

    converters, entity, field, name
  • Constructor Summary

    Constructors 
    Constructor Description
    PropertyOne2One​(@NotNull java.lang.String name, @NotNull java.lang.Class<T> entity, @NotNull net.tangly.commons.lang.Reference<Dao<R>> type, boolean owned)  
  • 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.

    Methods inherited from class net.tangly.orm.imp.PropertySimple

    entity, field, getConverter, jdbcType, name, sqlType

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.tangly.orm.Property

    get, getParameter, set, setParameter
  • Constructor Details

    • PropertyOne2One

      public PropertyOne2One​(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.Class<T> entity, @NotNull @NotNull net.tangly.commons.lang.Reference<Dao<R>> type, boolean owned)
  • Method Details

    • type

      public Dao<R> type()
      Description copied from interface: Relation
      Returns the DAO is charge of the objects at the end of the relation. Therefore only typed relations are supported.
      Specified by:
      type in interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
      Returns:
      the DAO of the objects at the end of the relation
    • isOwned

      public boolean isOwned()
      Description copied from interface: Relation
      Returns flag indicating if the instances at the end of the relation are owned or not.
      Specified by:
      isOwned in interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
      Returns:
      value of the flag
    • update

      public void update​(@NotNull T entity) throws java.security.PrivilegedActionException
      Description copied from interface: Relation
      Updates all the instances at the end of the relation.
      Specified by:
      update in interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
      Parameters:
      entity - entity owning the relation
      Throws:
      java.security.PrivilegedActionException - if an error occurred when accessing field for foreign key or instance
    • retrieve

      public void retrieve​(@NotNull T entity, java.lang.Long fid) throws java.security.PrivilegedActionException
      Description copied from interface: Relation
      Retrieves all the instances at the end of the relation.
      Specified by:
      retrieve in interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
      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

      public void delete​(@NotNull T entity) throws java.security.PrivilegedActionException
      Description copied from interface: Relation
      Deletes all the instances at the end of the relation. Semantically this method performs only if Relation.isOwned() returns true.
      Specified by:
      delete in interface Relation<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
      Parameters:
      entity - entity owning the relation
      Throws:
      java.security.PrivilegedActionException - if an error occurred when accessing field for foreign key or instance