java.lang.Object
er.extensions.eof.ERXUnmodeledToManyRelationship<S,D>
- Type Parameters:
S
- Relationship source EO objectD
- Relationship destination EO class.
public class ERXUnmodeledToManyRelationship<S extends ERXEnterpriseObject,D extends ERXEnterpriseObject>
- extends java.lang.Object
A class than is composited into an EO to provide common toMany functionality
for the case where the toMany cannot be modeled in EOF due to the unusually
large size possibilities of the toMany relationship.
This class is for simple to many relationships, has not been tested on
flattened toMany relationships having a join table, aka "many-to-many" relationships.
Usage: Lazily create a private instance of this inside an EO passing in the
appropriate constructor parameters and then implement cover methods similar
to those that would have been available thru the normal Entity templates
calling the corresponding methods of this class.
For example, you might do this in an entity named CTMediaTemplate that formerly had a 'messages'
relationship to CTMessage but due to the huge size of the toMany impacting performance, the toMany side of the
relationship had to be deleted from the EOModel:
private ERXUnmodeledToManyRelationship _messagesRelationship;
// Lazily initialize the helper class
public ERXUnmodeledToManyRelationship messagesRelationship() {
if (_messagesRelationship == null) {
_messagesRelationship = new ERXUnmodeledToManyRelationship(this,
CTMessage.ENTITY_NAME, CTMessage.XKEY_MEDIA_TEMPLATE);
}
return _messagesRelationship;
}
public Integer countMessages() {
return messagesRelationship().countObjects();
}
public EOQualifier qualifierForMessages() {
return messagesRelationship().qualifierForObjects();
}
public NSArray messages() {
return messagesRelationship().objects();
}
public ERXFetchSpecification fetchSpecificationForMessages() {
return messagesRelationship().fetchSpecificationForObjects();
}
public NSArray messages(EOQualifier qualifier) {
return messagesRelationship().objects(qualifier);
}
public NSArray messages(EOQualifier qualifier, boolean fetch) {
return messagesRelationship().objects(qualifier, null, fetch);
}
public NSArray messages(EOQualifier qualifier, NSArray sortOrderings, boolean fetch) {
return messagesRelationship().objects(qualifier, sortOrderings, fetch);
}
public void addToMessagesRelationship(CTMessage object) {
messagesRelationship().addToObjectsRelationship(object);
}
public void removeFromMessagesRelationship(CTMessage object) {
messagesRelationship().removeFromObjectsRelationship(object);
}
public void deleteMessagesRelationship(CTMessage object) {
messagesRelationship().deleteObjectRelationship(object);
}
public void deleteAllMessagesRelationships() {
messagesRelationship().deleteAllObjectsRelationships();
}
- Author:
- kieran
Constructor Summary |
ERXUnmodeledToManyRelationship(S sourceObject,
java.lang.String destinationEntityName,
ERXKey<S> reverseRelationshipKey)
Standard constructor where the destination entity is a single type. |
ERXUnmodeledToManyRelationship(S sourceObject,
java.lang.String destinationEntityName,
ERXKey<S> reverseRelationshipKey,
boolean isDeep)
A constructor that allows isDeep to be set to true to handle destination entity that is the super class of an inheritance hierarchy. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ERXUnmodeledToManyRelationship
public ERXUnmodeledToManyRelationship(S sourceObject,
java.lang.String destinationEntityName,
ERXKey<S> reverseRelationshipKey)
- Standard constructor where the destination entity is a single type. Excludes entities that might inherit from the destination entity
- Parameters:
sourceObject
- destinationEntityName
- reverseRelationshipKey
-
ERXUnmodeledToManyRelationship
public ERXUnmodeledToManyRelationship(S sourceObject,
java.lang.String destinationEntityName,
ERXKey<S> reverseRelationshipKey,
boolean isDeep)
- A constructor that allows isDeep to be set to true to handle destination entity that is the super class of an inheritance hierarchy.
The inherited entities are included in the methods that return arrays of destination EOEnterpriseObjects.
- Parameters:
sourceObject
- destinationEntityName
- reverseRelationshipKey
- isDeep
-
countObjects
public java.lang.Integer countObjects()
- Returns:
- the total count of objects in the relationship
qualifierForObjects
public com.webobjects.eocontrol.EOQualifier qualifierForObjects()
- Returns:
- the
EOQualifier
that qualifies the toMany destination
objects
objects
public com.webobjects.foundation.NSArray<D> objects()
- Returns:
- the related destination objects
fetchSpecificationForObjects
public ERXFetchSpecification<D> fetchSpecificationForObjects()
- Returns:
- the
ERXFetchSpecification
that fetches the destination
toMany objects that have been persisted to the database
objects
public com.webobjects.foundation.NSArray<D> objects(com.webobjects.eocontrol.EOQualifier qualifier)
objects
public com.webobjects.foundation.NSArray<D> objects(com.webobjects.eocontrol.EOQualifier qualifier,
boolean fetch)
objects
public com.webobjects.foundation.NSArray<D> objects(com.webobjects.eocontrol.EOQualifier qualifier,
com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings,
boolean fetch)
addToObjectsRelationship
public void addToObjectsRelationship(D object)
addToObjectsRelationship
public void addToObjectsRelationship(com.webobjects.foundation.NSArray<D> objects)
removeFromObjectsRelationship
public void removeFromObjectsRelationship(D object)
removeFromObjectsRelationship
public void removeFromObjectsRelationship(com.webobjects.foundation.NSArray<D> objects)
deleteObjectRelationship
public void deleteObjectRelationship(D object)
deleteAllObjectsRelationships
public void deleteAllObjectsRelationships()
Copyright © 2002 – 2007 Project Wonder.