|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.webobjects.eoaccess.EOProperty | +--com.webobjects.eoaccess.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.
setJoinSemantic(int joinSemantic)
,
InnerJoin
,
FullOuterJoin
,
LeftOuterJoin
,
RightOuterJoin
Field Summary | |
static int |
FullOuterJoin
Produces results for all source records, regardless of the values of the relationships. |
static int |
InnerJoin
Produces results only for destinations of the join relationship that have non- null values. |
static int |
LeftOuterJoin
Preserves rows in the left (source) table, keeping them even if there's no corresponding row in the right table. |
static int |
RightOuterJoin
Preserves rows in the right (destination) table, keeping them even if there's no corresponding row in the left table. |
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 dictionary)
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int FullOuterJoin
public static final int InnerJoin
null
values.public static final int LeftOuterJoin
public static final int RightOuterJoin
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 void addJoin(EOJoin join)
join
's
attributes already belongs to another join of the relationship.join
- specifies joins used by relationshipexception
- if the relationship is flattenedjoins()
,
isFlattened()
,
setDefinition(String definition)
public EORelationship anyInverseRelationship()
inverseRelationship()
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 void beautifyName()
setName(String name)
,
EOModel.beautifyNames()
public NSArray componentRelationships()
null
if the relationship isn't flattened.public String definition()
definition
returns null
.componentRelationships()
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 NSArray destinationAttributes()
sourceAttributes
.sourceAttributes()
public EOEntity destinationEntity()
entity()
public void encodeIntoPropertyList(NSMutableDictionary result)
EOPropertyListEncoding
encodeIntoPropertyList
in interface EOPropertyListEncoding
com.webobjects.eoaccess.EOPropertyListEncoding
dic
- A dictionary into which to encode the receiver.public EOEntity entity()
EODatabaseOperation.EODatabaseOperation(EOGlobalID aGlobalID,
Object anObject,
EOEntity anEntity)
public EORelationship inverseRelationship()
null
otherwise.null
otherwisepublic 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 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 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
setIsMandatory(boolean flag)
public 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.setToMany(boolean flag)
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. |
joins()
public NSArray joins()
destinationAttributes()
,
joinSemantic()
,
sourceAttributes()
public String name()
name
in class EOProperty
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
otherwisesetOwnsDestination(boolean flag)
,
destinationAttributes()
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 EOQualifier qualifierWithSourceRow(NSDictionary sourceRow)
sourceRow
.sourceRow
- row data (or "snapshot") for source objectpublic 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 relationshiptrue
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 relationshipPath()
name
.relationshipPath
in class EOProperty
public void removeJoin(EOJoin join)
join
from the relationship.
Does nothing if the relationship is flattened.join
- joins used by relationship.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 StringaddJoin(EOJoin aJoin)
,
setEntity(EOEntity anEntity)
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 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)
,
setDefinition(String definition)
public void setIsMandatory(boolean isMandatory)
isMandatory
whether the target of the relationship
must be supplied or can be null
.isMandatory
- specifies flagpublic void setJoinSemantic(int semantic)
joinSemantic
should be one of the following:
semantic
- specifies semantic used to create SQL expressionsInnerJoin
,
FullOuterJoin
,
LeftOuterJoin
,
RightOuterJoin
,
addJoin(EOJoin aJoin)
,
joinSemantic()
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 nameexception
- if name
is not a
valid relationship namebeautifyName()
public void setNumberOfToManyFaultsToBatchFetch(int size)
size
.size
- specifies number of faultsisToMany()
,
numberOfToManyFaultsToBatchFetch()
public 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 flagdeleteRule()
,
setDeleteRule(int deleteRule)
,
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 void setToMany(boolean bool)
bool
.
Throws an exception if the receiver is flattened.bool
- specifies flagexception
- if the receiver is flattenedisFlattened()
public void setUserInfo(NSDictionary dictionary)
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).dictionary
- specifies dictionary of auxiliary datapublic NSArray sourceAttributes()
destinationAttributes
. Returns null
if the
relationship is flattened.destinationAttributes()
,
joins()
,
EOJoin.sourceAttribute()
public String toString()
toString
in class Object
public NSDictionary userInfo()
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 valueNSValidation.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.isMandatory()
,
setIsMandatory(boolean flag)
public String valueForSQLExpression(EOSQLExpression context)
valueForSQLExpression
in interface EOSQLExpression.SQLValue
context
- SQL expression contextEOSQLExpression.SQLValue
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |