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

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

public class PropertyOne2Many<T extends net.tangly.bus.core.HasOid,​R extends net.tangly.bus.core.HasOid>
extends java.lang.Object
implements Property<T>, Relation<T,​R>
Models a propertyBy with managed objects as values and supporting multiple objects. When the propertyBy is read we retrieve all instances which foreign key format is equal to the unique object identifier oid of the owner of the propertyBy. When writing the foreign key propertyBy with the unique object identifier oid of the owner of the propertyBy and when persist all the objects.
  • Nested Class Summary

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

    Property.ConverterType
  • Constructor Summary

    Constructors 
    Constructor Description
    PropertyOne2Many​(@NotNull java.lang.String name, @NotNull java.lang.Class<T> entity, @NotNull java.lang.String property, @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.
    java.lang.Class<T> entity()
    Returns the type of the entity owning the property.
    java.lang.reflect.Field field()
    Returns the Java field associated with the property.
    <T1,​ R> java.util.function.Function<T1,​R> getConverter​(@NotNull Property.ConverterType type)  
    boolean isOwned()
    Returns flag indicating if the instances at the end of the relation are owned or not.
    java.lang.Class<?> jdbcType()  
    java.lang.String name()
    Returns the name of the property.
    void retrieve​(T entity, java.lang.Long fid)
    Retrieves all the instances at the end of the relation.
    int sqlType()  
    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 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

    • PropertyOne2Many

      public PropertyOne2Many​(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.Class<T> entity, @NotNull @NotNull java.lang.String property, @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
    • name

      public java.lang.String name()
      Description copied from interface: Property
      Returns the name of the property.
      Specified by:
      name in interface Property<T extends net.tangly.bus.core.HasOid>
      Returns:
      name of the property
    • entity

      public java.lang.Class<T> entity()
      Description copied from interface: Property
      Returns the type of the entity owning the property.
      Specified by:
      entity in interface Property<T extends net.tangly.bus.core.HasOid>
      Returns:
      type of the declaring entity
    • field

      public java.lang.reflect.Field field()
      Description copied from interface: Property
      Returns the Java field associated with the property.
      Specified by:
      field in interface Property<T extends net.tangly.bus.core.HasOid>
      Returns:
      field of the property
    • sqlType

      public int sqlType()
      Specified by:
      sqlType in interface Property<T extends net.tangly.bus.core.HasOid>
    • jdbcType

      public java.lang.Class<?> jdbcType()
      Specified by:
      jdbcType in interface Property<T extends net.tangly.bus.core.HasOid>
    • getConverter

      public <T1,​ R> java.util.function.Function<T1,​R> getConverter​(@NotNull @NotNull Property.ConverterType type)
      Specified by:
      getConverter in interface Property<T extends net.tangly.bus.core.HasOid>
    • 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