public class ERXUnmodeledToManyRelationship<S extends ERXEnterpriseObject,D extends ERXEnterpriseObject> extends Object
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<CTMediaTemplate, CTMessage> _messagesRelationship;
// Lazily initialize the helper class
public ERXUnmodeledToManyRelationship<CTMediaTemplate, CTMessage> messagesRelationship() {
if (_messagesRelationship == null) {
_messagesRelationship = new ERXUnmodeledToManyRelationship<CTMediaTemplate, CTMessage>(this,
CTMessage.ENTITY_NAME, CTMessage.XKEY_MEDIA_TEMPLATE);
}
return _messagesRelationship;
}
public Integer countMessages() {
return messagesRelationship().countObjects();
}
public EOQualifier qualifierForMessages() {
return messagesRelationship().qualifierForObjects();
}
public NSArray<CTMessage> messages() {
return messagesRelationship().objects();
}
public ERXFetchSpecification<CTMessage> fetchSpecificationForMessages() {
return messagesRelationship().fetchSpecificationForObjects();
}
public NSArray<CTMessage> messages(EOQualifier qualifier) {
return messagesRelationship().objects(qualifier);
}
public NSArray<CTMessage> messages(EOQualifier qualifier, boolean fetch) {
return messagesRelationship().objects(qualifier, null, fetch);
}
public NSArray<CTMessage> messages(EOQualifier qualifier, NSArray<EOSortOrdering> 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();
}
Constructor and Description |
---|
ERXUnmodeledToManyRelationship(S sourceObject,
String destinationEntityName,
ERXKey<S> reverseRelationshipKey)
Standard constructor where the destination entity is a single type.
|
ERXUnmodeledToManyRelationship(S sourceObject,
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addToObjectsRelationship(D object) |
void |
addToObjectsRelationship(NSArray<D> objects) |
Integer |
countObjects() |
void |
deleteAllObjectsRelationships() |
void |
deleteObjectRelationship(D object) |
ERXFetchSpecification<D> |
fetchSpecificationForObjects() |
NSArray<D> |
objects() |
NSArray<D> |
objects(EOQualifier qualifier) |
NSArray<D> |
objects(EOQualifier qualifier,
boolean fetch) |
NSArray<D> |
objects(EOQualifier qualifier,
NSArray<EOSortOrdering> sortOrderings,
boolean fetch) |
EOQualifier |
qualifierForObjects() |
void |
removeAllFromObjectsRelationship() |
void |
removeFromObjectsRelationship(D object) |
void |
removeFromObjectsRelationship(NSArray<D> objects) |
public ERXUnmodeledToManyRelationship(S sourceObject, String destinationEntityName, ERXKey<S> reverseRelationshipKey)
sourceObject
- destinationEntityName
- reverseRelationshipKey
- public ERXUnmodeledToManyRelationship(S sourceObject, String destinationEntityName, ERXKey<S> reverseRelationshipKey, boolean isDeep)
sourceObject
- destinationEntityName
- reverseRelationshipKey
- isDeep
- public Integer countObjects()
public EOQualifier qualifierForObjects()
EOQualifier
that qualifies the toMany destination
objectspublic ERXFetchSpecification<D> fetchSpecificationForObjects()
ERXFetchSpecification
that fetches the destination
toMany objects that have been persisted to the databasepublic NSArray<D> objects(EOQualifier qualifier)
public NSArray<D> objects(EOQualifier qualifier, boolean fetch)
public NSArray<D> objects(EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch)
public void addToObjectsRelationship(D object)
public void removeFromObjectsRelationship(D object)
public void removeAllFromObjectsRelationship()
public void deleteObjectRelationship(D object)
public void deleteAllObjectsRelationships()
Copyright © 2002 – 2024 Project Wonder.