Class Dao<T extends net.tangly.bus.core.HasOid>

java.lang.Object
net.tangly.orm.Dao<T>
Type Parameters:
T - the class being mapped. The table takes care of the handling of the unique object identifier.
All Implemented Interfaces:
net.tangly.bus.providers.InstanceProvider<T>, net.tangly.bus.providers.Provider<T>

public class Dao<T extends net.tangly.bus.core.HasOid>
extends java.lang.Object
implements net.tangly.bus.providers.InstanceProvider<T>
Represents the mapping between a Java class and a relational database table containing the values of the instances of the class. The design promotes convention over configuration. The primary key for an entity is always the first field with the name oid and of type long.
  • Constructor Summary

    Constructors 
    Constructor Description
    Dao​(java.lang.String schema, @NotNull java.lang.String entity, @NotNull java.lang.Class<T> type, @NotNull javax.sql.DataSource dataSource, @NotNull java.util.List<Property<T>> properties, @NotNull java.util.List<Relation<T,​?>> one2one, @NotNull java.util.List<Relation<T,​?>> one2many)  
  • Method Summary

    Modifier and Type Method Description
    void clearCache()  
    void delete​(long oid)  
    void delete​(T entity)  
    java.util.Optional<T> find​(long oid)  
    java.util.List<T> find​(java.lang.String where)  
    java.util.List<T> getAll()  
    java.util.Optional<Property<T>> getPropertyBy​(@NotNull java.lang.String name)
    Returns the property with the given name.
    java.lang.Class<T> type()  
    void update​(T entity)
    Updates the persistent data associated with the entity.If the entity is new a row is inserted into the table otherwise the columns are updated.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.tangly.bus.providers.Provider

    findBy, updateAll
  • Constructor Details

    • Dao

      public Dao​(java.lang.String schema, @NotNull @NotNull java.lang.String entity, @NotNull @NotNull java.lang.Class<T> type, @NotNull @NotNull javax.sql.DataSource dataSource, @NotNull @NotNull java.util.List<Property<T>> properties, @NotNull @NotNull java.util.List<Relation<T,​?>> one2one, @NotNull @NotNull java.util.List<Relation<T,​?>> one2many) throws java.lang.NoSuchMethodException
      Throws:
      java.lang.NoSuchMethodException
  • Method Details

    • type

      public java.lang.Class<T> type()
    • getPropertyBy

      public java.util.Optional<Property<T>> getPropertyBy​(@NotNull @NotNull java.lang.String name)
      Returns the property with the given name.
      Parameters:
      name - name of the property to be found
      Returns:
      optional found property
    • find

      public java.util.Optional<T> find​(long oid)
      Specified by:
      find in interface net.tangly.bus.providers.InstanceProvider<T extends net.tangly.bus.core.HasOid>
    • getAll

      public java.util.List<T> getAll()
      Specified by:
      getAll in interface net.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>
    • update

      public void update​(@NotNull T entity)
      Updates the persistent data associated with the entity.If the entity is new a row is inserted into the table otherwise the columns are updated. The update is transitive and all referenced entities are also updated.
      Specified by:
      update in interface net.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>
      Parameters:
      entity - entity to update
    • delete

      public void delete​(@NotNull T entity)
      Specified by:
      delete in interface net.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>
    • find

      public java.util.List<T> find​(java.lang.String where)
    • delete

      public void delete​(long oid)
    • clearCache

      public void clearCache()