Package net.tangly.orm
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 voidclearCache()voiddelete(long oid)voiddelete(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()voidupdate(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.
-
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
-
getPropertyBy
Returns the property with the given name.- Parameters:
name- name of the property to be found- Returns:
- optional found property
-
find
- Specified by:
findin interfacenet.tangly.bus.providers.InstanceProvider<T extends net.tangly.bus.core.HasOid>
-
getAll
- Specified by:
getAllin interfacenet.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>
-
update
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:
updatein interfacenet.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>- Parameters:
entity- entity to update
-
delete
- Specified by:
deletein interfacenet.tangly.bus.providers.Provider<T extends net.tangly.bus.core.HasOid>
-
find
-
delete
public void delete(long oid) -
clearCache
public void clearCache()
-