|
WebObjects 5.4.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoaccess.EOProperty com.webobjects.eoaccess.EORelationship
public class EORelationship
An EORelationship describes an association between two entities, based on attributes of those two entities. By defining EORelationships in the application's EOModel, you can cause the relationships defined in the database to be automatically resolved as Enterprise Objects are fetched. For
example, a Movie entity may contain its studioId
as an attribute, but without an EORelationship studioId
will appear in a Movie Enterprise Object only as a number. With an EORelationship explicitly connecting the Movie entity to a Studio entity, a Movie Enterprise
Object will automatically be given its Studio Enterprise Object when an EODatabaseChannel fetches it from the database. The two entities that make up a relationship can be in the same model or two different models, as long as they are in the same model group.
You usually can define relationships in your EOModel with the EOModeler application. EORelationships are primarily for use by the Enterprise Objects Framework; unless you have special needs you shouldn't need to access them in your application's code.
See EORelationshipConcepts for more information.
EORelationship.setJoinSemantic(int joinSemantic)
,
EORelationship.InnerJoin
,
EORelationship.FullOuterJoin
,
EORelationship.LeftOuterJoin
,
EORelationship.RightOuterJoin
Field Summary | |
---|---|
static String |
DeleteRuleCascadeString
|
static String |
DeleteRuleDenyString
|
static String |
DeleteRuleNoActionString
|
static String |
DeleteRuleNullifyString
|
static int |
FullOuterJoin
Produces results for all source records, regardless of the values of the relationships. |
static String |
FullOuterJoinString
|
static int |
InnerJoin
Produces results only for destinations of the join relationship that have non- null values. |
static String |
InnerJoinString
|
static int |
LeftOuterJoin
Preserves rows in the left (source) table, keeping them even if there's no corresponding row in the right table. |
static String |
LeftOuterJoinString
|
static int |
RightOuterJoin
Preserves rows in the right (destination) table, keeping them even if there's no corresponding row in the left table. |
static String |
RightOuterJoinString
|
Constructor Summary | |
---|---|
EORelationship()
Creates an empty EORelationship. |
|
EORelationship(NSDictionary plist,
EOEntity owner)
Creates and returns a new EORelationship initialized from plist -a dictionary containing only property list data types (that is, NSDictionaries, Strings, NSArrays, and NSData). |
Method Summary | |
---|---|
void |
addJoin(EOJoin join)
Adds a source-destination attribute pair to the relationship. |
EORelationship |
anyInverseRelationship()
Searches the relationship's destination entity for any back- referencing relationship joining on the same keys. |
void |
awakeWithPropertyList(NSDictionary plist)
Finishes initializing the receiver from plist . |
void |
beautifyName()
Makes the relationship's name conform to a standard convention. |
NSArray |
componentRelationships()
Returns an NSArray of base relationships making up a flattened relationship, or null if the relationship isn't flattened. |
String |
definition()
Returns the data path of a flattened relationship; for example "department.facility". |
int |
deleteRule()
Returns a rule that describes the action to take when an object is being deleted. |
NSArray |
destinationAttributes()
Returns an NSArray of destination attributes of the relationship. |
EOEntity |
destinationEntity()
Returns the relationship's destination entity, which is determined by the destination entity of its joins for a simple relationship, and by whatever ends the data path for a flattened relationship. |
void |
encodeIntoPropertyList(NSMutableDictionary result)
Encodes the receiver as a property list. |
EOEntity |
entity()
Returns the relationship's entity. |
EORelationship |
inverseRelationship()
Searches the relationship's destination entity for a user-created, back- referencing relationship joining on the same keys. |
boolean |
isCompound()
Returns true if the relationship contains more than one join (that is, if it joins more than one pair of attributes), false if it has only one join. |
boolean |
isFlattened()
Returns true if the relationship has a definition that traverses another relationship, false otherwise. |
boolean |
isMandatory()
Returns true if the target of the relationship is required, false if it can be null . |
boolean |
isToMany()
Returns true if the relationship is to-many, false if it's to-one. |
NSArray |
joins()
Returns all joins used by relationship. |
int |
joinSemantic()
Returns the semantic used to create SQL expressions for this relationship. |
String |
name()
Returns the relationship's name. |
int |
numberOfToManyFaultsToBatchFetch()
Returns the number of to-many faults that are triggered at one time. |
boolean |
ownsDestination()
Returns true if the receiver's source object owns its destination objects, false otherwise. |
boolean |
propagatesPrimaryKey()
Returns true if objects should propagate their primary key to related objects through this relationship. |
EOQualifier |
qualifierWithSourceRow(NSDictionary sourceRow)
Returns a qualifier that can be used to fetch the destination of the receiving relationship given sourceRow . |
boolean |
referencesProperty(Object property)
Returns true if property is in the relationship's data path or is an attribute belonging to one of the relationship's joins; otherwise, it returns false . |
String |
relationshipPath()
Returns the full relationship path for a flattened relationship. |
void |
removeJoin(EOJoin join)
Deletes join from the relationship. |
void |
setDefinition(String definition)
Changes the relationship to a flattened relationship by releasing any joins and attributes (both source and destination) associated with the relationship and setting definition as its data path. |
void |
setDeleteRule(int deleteRule)
Set a rule describing the action to take when object is being deleted. |
void |
setEntity(EOEntity entity)
Sets the entity of the relationship to entity . |
void |
setIsMandatory(boolean isMandatory)
Specifies according to isMandatory whether the target of the relationship must be supplied or can be null . |
void |
setJoinSemantic(int semantic)
Sets the semantic used to create SQL expressions for this relationship. |
void |
setName(String name)
Sets the relationship's name to name . |
void |
setNumberOfToManyFaultsToBatchFetch(int size)
Sets the number of "toMany" faults that are fired at one time to size . |
void |
setOwnsDestination(boolean bool)
Sets according to bool whether a receiver's source object owns its destination objects. |
void |
setPropagatesPrimaryKey(boolean bool)
Specifies according to bool whether objects should propagate their primary key to related objects through this relationship. |
void |
setToMany(boolean bool)
Sets a simple relationship as to-many according to bool . |
void |
setUserInfo(NSDictionary aDictionary)
Sets the dictionary of auxiliary data, which the application can use for whatever it needs. |
NSArray |
sourceAttributes()
Returns the source attributes of a simple (non-flattened) relationship. |
String |
toString()
|
NSDictionary |
userInfo()
Returns a dictionary of user data. |
Object |
validateValue(Object valueP)
For relationships marked as mandatory, throws a ValidationException if the receiver is to-one and valueP is null , or if the receiver is to-many and valueP has a count of 0. |
String |
valueForSQLExpression(EOSQLExpression context)
Returns the value to use in SQL expressions. |
Methods inherited from class com.webobjects.eoaccess.EOProperty |
---|
equals, initialCapitalName |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int InnerJoin
null
values.
public static final String InnerJoinString
public static final int FullOuterJoin
public static final String FullOuterJoinString
public static final int LeftOuterJoin
public static final String LeftOuterJoinString
public static final int RightOuterJoin
public static final String RightOuterJoinString
public static final String DeleteRuleNullifyString
public static final String DeleteRuleCascadeString
public static final String DeleteRuleDenyString
public static final String DeleteRuleNoActionString
Constructor Detail |
---|
public EORelationship(NSDictionary plist, EOEntity owner)
plist
-a dictionary containing only property list data types (that is, NSDictionaries, Strings, NSArrays, and NSData). This constructor is used by EOModeler when it reads in a Model from a file, for example. The
owner
argument should be the EORelationship's Entity. EORelationships created from a property list must receive an awakeWithPropertyList
message immediately after creation before they are fully functional, but the awakeWithPropertyList
message
should be deferred until after all of the other objects in the model have also been created.
plist
- dictionary containing property listowner
- specify entity as ownerpublic EORelationship()
Method Detail |
---|
public String name()
name
in class EOProperty
public EOEntity entity()
entity
in class EOProperty
EODatabaseOperation.EODatabaseOperation(EOGlobalID aGlobalID, Object anObject, EOEntity anEntity)
public EOEntity destinationEntity()
EORelationship.entity()
public String definition()
definition
returns null
.
EORelationship.componentRelationships()
public NSArray componentRelationships()
null
if the relationship isn't flattened.
public boolean isFlattened()
true
if the relationship has a definition that traverses another relationship, false
otherwise. A flattened relationship gives the source entity access to the relationships in a destination entity.
true
if the relationship is flattened, false
otherwisepublic boolean isToMany()
true
if the relationship is to-many, false
if it's to-one.
true
if the relationship is to-many, false
if it's to-one.EORelationship.setToMany(boolean flag)
public boolean isCompound()
true
if the relationship contains more than one join (that is, if it joins more than one pair of attributes), false
if it has only one join.
true
if the relationship contains more than one join, false
if it has only one joinpublic NSArray sourceAttributes()
destinationAttributes
. Returns null
if the relationship is flattened.
EORelationship.destinationAttributes()
,
EORelationship.joins()
,
EOJoin.sourceAttribute()
public NSArray destinationAttributes()
sourceAttributes
.
EORelationship.sourceAttributes()
public String valueForSQLExpression(EOSQLExpression context)
valueForSQLExpression
in interface EOSQLExpression.SQLValue
context
- SQL expression context
EOSQLExpression.SQLValue
public NSDictionary userInfo()
public boolean referencesProperty(Object property)
true
if property
is in the relationship's data path or is an attribute belonging to one of the relationship's joins; otherwise, it returns false
.
property
- specifies property of the relationship
true
if property
is in the relationship's data path or is an attribute belonging to one of the relationship's joins; otherwise, it returns false
.EOEntity.referencesProperty(Object aProperty)
public String toString()
toString
in class Object
public NSArray joins()
EORelationship.destinationAttributes()
,
EORelationship.joinSemantic()
,
EORelationship.sourceAttributes()
public int joinSemantic()
Constant | Description |
InnerJoin |
Produces results only for destinations of the join relationship that have non-null values. |
FullOuterJoin |
Produces results for all source records, regardless of the values of the relationships. |
LeftOuterJoin |
Preserves rows in the left (source) table, keeping them even if there's no corresponding row in the right table. |
RightOuterJoin |
Preserves rows in the right (destination) table, keeping them even if there's no corresponding row in the left table. |
EORelationship.joins()
public EORelationship inverseRelationship()
null
otherwise.
null
otherwisepublic EORelationship anyInverseRelationship()
EORelationship.inverseRelationship()
public int numberOfToManyFaultsToBatchFetch()
public boolean ownsDestination()
true
if the receiver's source object owns its destination objects, false
otherwise.
true
if the receiver's source object owns its destination objects, false
otherwiseEORelationship.setOwnsDestination(boolean flag)
,
EORelationship.destinationAttributes()
public int deleteRule()
Value | Description |
EOClassDescription. DeleteRuleNullify |
Delete the department and remove any back reference the employee has to the department. |
EOClassDescription. DeleteRuleCascade |
Delete the department and all of the employees it contains. |
EOClassDescription. DeleteRuleDeny |
Refuse the deletion if the department contains employees. |
EOClassDescription. DeleteRuleNoAction |
Delete the department, but ignore the department's employees relationship. You should use this delete rule with caution since it can leave dangling references in your object graph. |
EOClassDescription
public boolean isMandatory()
true
if the target of the relationship is required, false
if it can be null
.
true
if the target of the relationship is required, false
if it can be null
EORelationship.setIsMandatory(boolean flag)
public boolean propagatesPrimaryKey()
true
if objects should propagate their primary key to related objects through this relationship. Objects only propagate their primary key values if the corresponding values in the destination object aren't already set.
true
if objects should propagate their primary key to related objects through this relationshippublic void encodeIntoPropertyList(NSMutableDictionary result)
EOPropertyListEncoding
encodeIntoPropertyList
in interface EOPropertyListEncoding
result
- A dictionary into which to encode the receiver.public void awakeWithPropertyList(NSDictionary plist)
plist
.
The receiver must have been created with a constructor of the form:
public ClassName(NSDictionary propertyList, Object owner)
awakeWithPropertyList
is responsible for restoring references to other objects. It should not be invoked until all other objects that the receiver might reference have been created from plist
.
awakeWithPropertyList
in interface EOPropertyListEncoding
plist
- dictionary containing property listpublic EOQualifier qualifierWithSourceRow(NSDictionary sourceRow)
sourceRow
.
sourceRow
- row data (or "snapshot") for source object
public void setName(String name)
name
. Throws a verification exception if name
is not a valid relationship name, and an invalid argument exception if name
is already in use by an attribute or another relationship in the same entity. This method
forces all objects in the model to be loaded into memory.
name
- specifies relationship's name
exception
- if name
is not a valid relationship nameEORelationship.beautifyName()
public void setDefinition(String definition)
definition
as its data path. For example, a relationship have the definitions "department.facility"
.
If the relationship's entity hasn't been set, this method won't work correctly.
definition
- a key path StringEORelationship.addJoin(EOJoin aJoin)
,
EORelationship.setEntity(EOEntity anEntity)
public void setEntity(EOEntity entity)
entity
. If the relationship is currently owned by a different entity, this method will remove the relationship from that entity. This method doesn't add the relationship to the new entity. EOEntity's addRelationship
method
invokes this method. You only need to use this method when creating a flattened relationship; use EOEntity's addRelationship
to associate an existing relationship with an entity.
entity
- specifies entityEOEntity.addRelationship(EORelationship aRelationship)
,
EORelationship.setDefinition(String definition)
public void setToMany(boolean bool)
bool
. Throws an exception if the receiver is flattened.
bool
- specifies flag
exception
- if the receiver is flattenedEORelationship.isFlattened()
public void setJoinSemantic(int semantic)
joinSemantic
should be one of the following:
semantic
- specifies semantic used to create SQL expressionsEORelationship.InnerJoin
,
EORelationship.FullOuterJoin
,
EORelationship.LeftOuterJoin
,
EORelationship.RightOuterJoin
,
EORelationship.addJoin(EOJoin aJoin)
,
EORelationship.joinSemantic()
public void addJoin(EOJoin join)
join
's attributes already belongs to another join of the relationship.
join
- specifies joins used by relationship
exception
- if the relationship is flattenedEORelationship.joins()
,
EORelationship.isFlattened()
,
EORelationship.setDefinition(String definition)
public void removeJoin(EOJoin join)
join
from the relationship. Does nothing if the relationship is flattened.
join
- joins used by relationship.public void setUserInfo(NSDictionary aDictionary)
dictionary
of auxiliary data, which the application can use for whatever it needs. dictionary
can only contain property list data types (that is, NSDictionary, String, NSArray, and NSData).
aDictionary
- specifies dictionary of auxiliary datapublic void beautifyName()
EORelationship.setName(String name)
,
EOModel.beautifyNames()
public void setNumberOfToManyFaultsToBatchFetch(int size)
size
.
size
- specifies number of faultsEORelationship.isToMany()
,
EORelationship.numberOfToManyFaultsToBatchFetch()
public void setDeleteRule(int deleteRule)
deleteRule
can be one of the following (defined in the control layer's EOClassDescription):
EOClassDescription.DeleteRuleNullify
EOClassDescription.DeleteRuleCascade
EOClassDescription.DeleteRuleDeny
EOClassDescription.DeleteRuleNoAction
deleteRule
- specifies rule describing the action to take when object is being deletedpublic void setIsMandatory(boolean isMandatory)
isMandatory
whether the target of the relationship must be supplied or can be null
.
isMandatory
- specifies flagpublic void setOwnsDestination(boolean bool)
bool
whether a receiver's source object owns its destination objects. The default is false
. When a source object owns its destination objects, it means that the destination objects can't exist independently. For example, in a personnel
database, dependents can't exist without having an associated employee. Removing a dependent from an employee's dependents array would have the effect of also deleting the dependent from the database, unless you transferred the dependent to a different employee.
bool
- specifies flagEORelationship.deleteRule()
,
EORelationship.setDeleteRule(int deleteRule)
,
EORelationship.ownsDestination()
public void setPropagatesPrimaryKey(boolean bool)
bool
whether objects should propagate their primary key to related objects through this relationship. For example, an Employee object might propagate its primary key to an EmployeePhoto object. Objects only propagate their primary key values if the
corresponding values in the destination object aren't already set.
bool
- specifies flagpublic String relationshipPath()
name
.
relationshipPath
in class EOProperty
EOAttribute
,
EOAttribute.relationshipPath()
,
EORelationship
,
EORelationship.relationshipPath()
public Object validateValue(Object valueP) throws NSValidation.ValidationException
ValidationException
if the receiver is to-one and valueP
is null
, or if the receiver is to-many and valueP
has a count of 0. A mandatory relationship is one in which the target of the
relationship is required. Returns the validated value (usually valueP
).
valueP
- specifies value
NSValidation.ValidationException
- if the receiver is to-one and valueP
is null
or if the receiver is to-many an valueP
has a count of 0.EORelationship.isMandatory()
,
EORelationship.setIsMandatory(boolean flag)
|
Last updated June 2008 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |