Package net.tangly.orm
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 relationR- 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 voiddelete(T entity)Deletes all the instances at the end of the relation.booleanisOwned()Returns flag indicating if the instances at the end of the relation are owned or not.voidretrieve(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.voidupdate(T entity)Updates all the instances at the end of the relation.
-
Method Details
-
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
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.PrivilegedActionExceptionRetrieves all the instances at the end of the relation.- Parameters:
entity- entity owning the relationfid- foreign key of the referenced entities. Currently in aN -> 1relation the fid is the oid of the referenced object, in a1 -> Nthe fid is the oid of entity- Throws:
java.security.PrivilegedActionException- if an error occurred when accessing field for foreign key or instance
-
delete
Deletes all the instances at the end of the relation. Semantically this method performs only ifisOwned()returns true.- Parameters:
entity- entity owning the relation- Throws:
java.security.PrivilegedActionException- if an error occurred when accessing field for foreign key or instance
-