Package net.tangly.orm.imp
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 propertyByR- Class referenced by the propertyBy
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
-
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 voiddelete(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.Fieldfield()Returns the Java field associated with the property.<T1, R> java.util.function.Function<T1,R>getConverter(@NotNull Property.ConverterType type)booleanisOwned()Returns flag indicating if the instances at the end of the relation are owned or not.java.lang.Class<?>jdbcType()java.lang.Stringname()Returns the name of the property.voidretrieve(T entity, java.lang.Long fid)Retrieves all the instances at the end of the relation.intsqlType()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.
-
Constructor Details
-
Method Details
-
type
Description copied from interface:RelationReturns the DAO is charge of the objects at the end of the relation. Therefore only typed relations are supported. -
name
public java.lang.String name()Description copied from interface:PropertyReturns the name of the property. -
entity
Description copied from interface:PropertyReturns the type of the entity owning the property. -
field
public java.lang.reflect.Field field()Description copied from interface:PropertyReturns the Java field associated with the property. -
sqlType
public int sqlType() -
jdbcType
public java.lang.Class<?> jdbcType() -
getConverter
public <T1, R> java.util.function.Function<T1,R> getConverter(@NotNull @NotNull Property.ConverterType type)- Specified by:
getConverterin interfaceProperty<T extends net.tangly.bus.core.HasOid>
-
isOwned
public boolean isOwned()Description copied from interface:RelationReturns flag indicating if the instances at the end of the relation are owned or not. -
update
Description copied from interface:RelationUpdates all the instances at the end of the relation. -
retrieve
public void retrieve(@NotNull T entity, java.lang.Long fid) throws java.security.PrivilegedActionExceptionDescription copied from interface:RelationRetrieves all the instances at the end of the relation.- Specified by:
retrievein interfaceRelation<T extends net.tangly.bus.core.HasOid,R extends net.tangly.bus.core.HasOid>- 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
Description copied from interface:RelationDeletes all the instances at the end of the relation. Semantically this method performs only ifRelation.isOwned()returns true.
-