public class ObjRelationship extends Relationship implements ConfigurationNode
Modifier and Type | Field and Description |
---|---|
protected String |
collectionType
Stores the type of collection mapped by a to-many relationship.
|
protected List<DbRelationship> |
dbRelationships |
static String |
DEFAULT_COLLECTION_TYPE
Denotes a default type of to-many relationship collection which is a Java
List.
|
protected int |
deleteRule |
protected String |
mapKey
Stores a property name of a target entity used to create a relationship
map.
|
protected boolean |
usedForLocking |
name, runtime, sourceEntity, targetEntityName, toMany
Constructor and Description |
---|
ObjRelationship() |
ObjRelationship(String name) |
Modifier and Type | Method and Description |
---|---|
<T> T |
acceptVisitor(ConfigurationNodeVisitor<T> visitor) |
void |
addDbRelationship(DbRelationship dbRel)
Appends a DbRelationship to the existing list of DbRelationships.
|
void |
clearDbRelationships() |
ObjRelationship |
createReverseRelationship()
Creates a complimentary reverse relationship from target entity to the
source entity.
|
void |
encodeAsXML(XMLEncoder encoder)
Prints itself as XML to the provided XMLEncoder.
|
ObjRelationship |
getClientRelationship()
Returns an ObjAttribute stripped of any server-side information, such as
DbAttribute mapping.
|
String |
getCollectionType()
Returns the interface of collection mapped by a to-many relationship.
|
String |
getDbRelationshipPath()
Returns a dot-separated path over mapped DbRelationships.
|
List<DbRelationship> |
getDbRelationships()
Returns an immutable list of underlying DbRelationships.
|
int |
getDeleteRule()
Returns the deleteRule.
|
String |
getMapKey()
Returns a property name of a target entity used to create a relationship
map.
|
String |
getReverseDbRelationshipPath()
Returns a reversed dbRelationship path.
|
ObjRelationship |
getReverseRelationship()
Returns a "complimentary" ObjRelationship going in the opposite
direction.
|
String |
getReverseRelationshipName()
Returns the name of a complimentary relationship going in the opposite
direction or null if it doesn't exist.
|
ObjEntity |
getSourceEntity()
Returns relationship source entity.
|
ObjEntity |
getTargetEntity()
Returns a target ObjEntity of this relationship.
|
boolean |
isFlattened()
Returns true if the relationship is a "flattened" relationship.
|
boolean |
isMandatory()
Returns if relationship is mandatory
|
boolean |
isOptional()
Returns a boolean indicating whether the presence of a non-null source
key(s) will not guarantee a presence of a target record.
|
boolean |
isReadOnly()
Returns true if the relationship is flattened, but is not of the single
case that can have automatic write support.
|
boolean |
isSourceDefiningTargetPrecenseAndType(EntityResolver entityResolver)
Returns true if the relationship is non-optional and target has no
subclasses.
|
boolean |
isSourceIndependentFromTargetChange()
Returns a boolean indicating whether modifying a target of such
relationship in any way will not change the underlying table row of the
source.
|
boolean |
isToDependentEntity()
Returns true if underlying DbRelationships point to dependent entity.
|
boolean |
isToMany()
Returns a boolean value that determines relationship multiplicity.
|
boolean |
isToPK()
Returns true if the underlying DbRelationships point to a at least one of
the columns of the target entity.
|
boolean |
isUsedForLocking()
Returns whether this attribute should be used for locking.
|
void |
recalculateReadOnlyValue()
Recalculates a new readonly value based on the underlying
DbRelationships.
|
void |
recalculateToManyValue()
Recalculates whether a relationship is toMany or toOne, based on the
underlying db relationships.
|
void |
removeDbRelationship(DbRelationship dbRel)
Removes the relationship
dbRel from the list of
relationships. |
void |
setCollectionType(String collectionType) |
void |
setDbRelationshipPath(String relationshipPath)
Sets mapped DbRelationships as a dot-separated path.
|
void |
setDeleteRule(int value)
Sets the delete rule of the relationship.
|
void |
setMapKey(String mapKey) |
void |
setUsedForLocking(boolean usedForLocking)
Sets whether this attribute should be used for locking.
|
String |
toString()
Overrides Object.toString() to return informative description.
|
getName, getParent, getTargetEntityName, isRuntime, setName, setParent, setRuntime, setSourceEntity, setTargetEntityName, setTargetEntityName
public static final String DEFAULT_COLLECTION_TYPE
protected int deleteRule
protected boolean usedForLocking
protected List<DbRelationship> dbRelationships
protected String collectionType
protected String mapKey
public ObjRelationship()
public ObjRelationship(String name)
public ObjEntity getSourceEntity()
Relationship
getSourceEntity
in class Relationship
public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
acceptVisitor
in interface ConfigurationNode
public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
public ObjEntity getTargetEntity()
getTargetEntity
in class Relationship
public String getReverseRelationshipName()
public ObjRelationship getReverseRelationship()
getReverseRelationship
in class Relationship
public ObjRelationship createReverseRelationship()
CayenneRuntimeException
if
reverse DbRelationship is not mapped.public List<DbRelationship> getDbRelationships()
public void addDbRelationship(DbRelationship dbRel)
public void removeDbRelationship(DbRelationship dbRel)
dbRel
from the list of
relationships.public void clearDbRelationships()
public boolean isOptional()
public boolean isSourceDefiningTargetPrecenseAndType(EntityResolver entityResolver)
public boolean isSourceIndependentFromTargetChange()
public boolean isToDependentEntity()
public boolean isToPK()
public boolean isFlattened()
isReadOnly()
public boolean isReadOnly()
public boolean isToMany()
Relationship
isToMany
in class Relationship
public int getDeleteRule()
setDeleteRule(int)
public void setDeleteRule(int value)
value
- New delete rule. Must be one of the constants defined in
DeleteRule class.IllegalArgumentException
- if the value is not a valid delete rule.DeleteRule
public boolean isUsedForLocking()
public void setUsedForLocking(boolean usedForLocking)
public String getDbRelationshipPath()
public String getReverseDbRelationshipPath() throws ExpressionException
ExpressionException
public void setDbRelationshipPath(String relationshipPath)
public void recalculateToManyValue()
public void recalculateReadOnlyValue()
public String toString()
Relationship
toString
in class Relationship
public ObjRelationship getClientRelationship()
public String getCollectionType()
public void setCollectionType(String collectionType)
public String getMapKey()
null
if
the default (PK) is used as the map key.public void setMapKey(String mapKey)
public boolean isMandatory()
Relationship
isMandatory
in class Relationship
Copyright © 2001–2019 Apache Cayenne. All rights reserved.