Package org.apache.cayenne.map
Class Relationship
java.lang.Object
org.apache.cayenne.map.Relationship
- All Implemented Interfaces:
Serializable,CayenneMapEntry,XMLSerializable
- Direct Known Subclasses:
DbRelationship,ObjRelationship
public abstract class Relationship extends Object implements CayenneMapEntry, XMLSerializable, Serializable
Defines a relationship between two entities. In a DataMap graph relationships represent
"arcs" connecting entity "nodes". Relationships are directional, i.e. they have a
notion of source and target entity. This makes DataMap a "digraph".
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected Stringnameprotected booleanruntimeA flag that specifies whether a Relationship was mapped by the user or added dynamically by Cayenne runtime.protected EntitysourceEntityprotected StringtargetEntityNameprotected booleantoMany -
Constructor Summary
Constructors Constructor Description Relationship()Creates an unnamed relationship.Relationship(String name)Creates a named relationship. -
Method Summary
Modifier and Type Method Description StringgetName()Returns the name property of this object.ObjectgetParent()Returns the parent map.abstract RelationshipgetReverseRelationship()Returns a "complimentary" relationship going in the opposite direction.EntitygetSourceEntity()Returns relationship source entity.abstract EntitygetTargetEntity()Returns a target entity of the relationship.StringgetTargetEntityName()Returns the name of a target entity.abstract booleanisMandatory()Returns if relationship is mandatorybooleanisRuntime()booleanisToMany()Returns a boolean value that determines relationship multiplicity.voidsetName(String name)voidsetParent(Object parent)Stores the parent map.voidsetRuntime(boolean synthetic)voidsetSourceEntity(Entity sourceEntity)Sets relationship source entity.voidsetTargetEntityName(String targetEntityName)Sets the name of relationship target entity.voidsetTargetEntityName(Entity targetEntity)Sets relationship target entity.StringtoString()Overrides Object.toString() to return informative description.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.cayenne.util.XMLSerializable
encodeAsXML
-
Field Details
-
name
-
sourceEntity
-
targetEntityName
-
toMany
protected boolean toMany -
runtime
protected boolean runtimeA flag that specifies whether a Relationship was mapped by the user or added dynamically by Cayenne runtime.- Since:
- 3.0
-
-
Constructor Details
-
Relationship
public Relationship()Creates an unnamed relationship. -
Relationship
Creates a named relationship.
-
-
Method Details
-
getName
Description copied from interface:CayenneMapEntryReturns the name property of this object.- Specified by:
getNamein interfaceCayenneMapEntry- Returns:
- name of this entry.
-
setName
-
getSourceEntity
Returns relationship source entity. -
setSourceEntity
Sets relationship source entity. -
getTargetEntity
Returns a target entity of the relationship. -
setTargetEntityName
Sets relationship target entity. Internally callssetTargetEntityName. -
getTargetEntityName
Returns the name of a target entity. -
setTargetEntityName
Sets the name of relationship target entity. -
isToMany
public boolean isToMany()Returns a boolean value that determines relationship multiplicity. This defines semantics of the connection between two nodes described by the source and target entities. E.g. to-many relationship between two Persistent object classes means that a source object would have a collection of target objects. This is a read-only property. -
getParent
Description copied from interface:CayenneMapEntryReturns the parent map.- Specified by:
getParentin interfaceCayenneMapEntry
-
setParent
Description copied from interface:CayenneMapEntryStores the parent map.- Specified by:
setParentin interfaceCayenneMapEntry
-
toString
Overrides Object.toString() to return informative description. -
isRuntime
public boolean isRuntime()- Since:
- 3.0
-
setRuntime
public void setRuntime(boolean synthetic)- Since:
- 3.0
-
getReverseRelationship
Returns a "complimentary" relationship going in the opposite direction. Returns null if no such relationship is found.- Since:
- 3.1
-
isMandatory
public abstract boolean isMandatory()Returns if relationship is mandatory- Since:
- 3.1
-