/** * Returns a non-null relationship object for this query. */ public ObjRelationship getRelationship(EntityResolver resolver) { updateMetadata(resolver); return arc.getRelationship(); }
private boolean visitRelationship(ArcProperty arc) { DbRelationship dbRel = arc.getRelationship().getDbRelationships().get(0); for (DbAttribute attribute : dbRel.getSourceAttributes()) { String target = attribute.getName(); appendColumn(targetSource, target, prefix + target); } return true; } });
void indexAddedProperty(PropertyDescriptor property) { if (property instanceof AttributeProperty) { AttributeProperty attributeProperty = (AttributeProperty) property; ObjAttribute attribute = attributeProperty.getAttribute(); if (attribute.isPrimaryKey()) { if (idProperties == null) { idProperties = new ArrayList<>(2); } idProperties.add(attributeProperty); } } else if (property instanceof ArcProperty) { ObjRelationship relationship = ((ArcProperty) property).getRelationship(); ObjRelationship reverseRelationship = relationship.getReverseRelationship(); if (reverseRelationship != null && "java.util.Map".equals(reverseRelationship.getCollectionType())) { if (mapArcProperties == null) { mapArcProperties = new ArrayList<>(2); } mapArcProperties.add((ArcProperty) property); } } }
ResultScanParentAttachmentStrategy(PrefetchProcessorNode node) { if (node.getParent() == null) { throw new IllegalArgumentException( "ResultScanParentAttachmentStrategy works only for non-root nodes"); } this.node = node; parentNode = (PrefetchProcessorNode) node.getParent(); ObjRelationship relationship = node.getIncoming().getRelationship(); List<DbRelationship> dbRelationships = relationship.getDbRelationships(); if (dbRelationships.size() > 1) { throw new IllegalArgumentException( "ResultScanParentAttachmentStrategy does not work for flattened relationships"); } joins = dbRelationships.get(0).getJoins().toArray( new DbJoin[dbRelationships.get(0).getJoins().size()]); }
private void visitRelationship(ArcProperty property) { ObjRelationship rel = property.getRelationship(); DbRelationship dbRel = rel.getDbRelationships().get(0); for (DbJoin join : dbRel.getJoins()) { DbAttribute src = join.getSource(); appendColumn(idVar, null, src, fields); } } };
private void visitRelationship(ArcProperty property) { resetJoinStack(); ObjRelationship rel = property.getRelationship(); DbRelationship dbRel = rel.getDbRelationships().get(0); List<DbJoin> joins = dbRel.getJoins(); for (DbJoin join : joins) { DbAttribute src = join.getSource(); appendColumn(columns, null, src, attributes, null, tableAlias); } } };
public boolean visitToMany(ToManyProperty property) { // connect reverse arc if the relationship is marked as // "runtime" ArcProperty reverseArc = property.getComplimentaryReverseArc(); boolean autoConnectReverse = reverseArc != null && reverseArc.getRelationship().isRuntime(); property.addTarget(source, target, autoConnectReverse); return false; }
private void connect(Persistent object, List<Persistent> related) { if (incoming.getRelationship().isToMany()) { ValueHolder toManyList = (ValueHolder) incoming.readProperty(object); // TODO, Andrus 11/15/2005 - if list is modified, shouldn't we attempt to // merge the changes instead of overwriting? toManyList.setValueDirectly(related != null ? related : new ArrayList(1)); } else { // this should've been handled elsewhere throw new CayenneRuntimeException("To-one relationship wasn't handled properly: %s", incoming.getName()); } }
@Override public boolean visitIdentificationVariable(EJBQLExpression expression) { PropertyDescriptor property = descriptor.getProperty(expression.getText()); if (property instanceof ArcProperty) { incoming = ((ArcProperty) property).getRelationship(); descriptor = ((ArcProperty) property).getTargetDescriptor(); } else { throw new EJBQLException("Incorrect relationship path: " + expression.getText()); } return true; }
ObjRelationship relationship = property.getRelationship(); if (relationship.isFlattened()) {
ObjRelationship relationship = processorNode.getIncoming().getRelationship();
JoinedIdParentAttachementStrategy(GraphManager graphManager, PrefetchProcessorNode node) { ClassDescriptor parentDescriptor = ((PrefetchProcessorNode) node.getParent()) .getResolver() .getDescriptor(); relatedIdPrefix = node .getIncoming() .getRelationship() .getReverseDbRelationshipPath() + "."; sourceEntities = parentDescriptor.getEntityInheritanceTree().allSubEntities(); this.node = node; this.graphManager = graphManager; }
void connectToParents() { // to-one's were connected earlier... if (isPartitionedByParent()) { // depending on whether parent is a "phantom" node, // use different strategy PrefetchProcessorNode parent = (PrefetchProcessorNode) getParent(); boolean parentObjectsExist = parent.getObjects() != null && parent.getObjects().size() > 0; if (incoming.getRelationship().isToMany()) { if (parentObjectsExist) { connectToNodeParents(parent.getObjects()); } else { connectToFaultedParents(); } } else { // optional to-one ... need to fill in unresolved relationships with // null... if (parentObjectsExist) { clearNullRelationships(parent.getObjects()); } } } }
public boolean visitToMany(ToManyProperty property) { // connect reverse arc if the relationship is marked as // "runtime" ArcProperty reverseArc = property.getComplimentaryReverseArc(); boolean autoConnectReverse = reverseArc != null && reverseArc.getRelationship().isRuntime(); Persistent target = findObject(targetNodeId); if (target == null) { // this is usually the case when a NEW object was // deleted and then // its // relationships were manipulated; so try to locate the // object in // the // collection ... // the performance of this is rather dubious of // course... target = findObjectInCollection(targetNodeId, property.readProperty(source)); } if (target == null) { // ignore? } else { property.removeTarget(source, target, autoConnectReverse); } return false; }
incoming = ((ArcProperty) property).getRelationship(); descriptor = ((ArcProperty) property).getTargetDescriptor(); pathRelationshipString = buffer.substring(0, buffer.length());
&& !getParent().isPhantom() && getIncoming() != null && !getIncoming().getRelationship().isFlattened()) { .getRelationship() .getDbRelationships() .get(0);
} else if (node.isJointPrefetch()) { node.setParentAttachmentStrategy(new StackLookupParentAttachmentStrategy(node)); } else if (node.getIncoming().getRelationship().isSourceIndependentFromTargetChange()) { node.setParentAttachmentStrategy(new JoinedIdParentAttachementStrategy(context.getGraphManager(), node)); } else {