/** Returns true if the specified attribute denotes a single valued * or collection valued relationship attribute. */ public boolean isRelationship(Object ownerClass, String attribute) { DatabaseMapping mapping = resolveAttributeMapping(ownerClass, attribute); return (mapping != null) && mapping.isForeignReferenceMapping(); }
/** Returns true if the specified attribute denotes a single valued * or collection valued relationship attribute. */ public boolean isRelationship(Object ownerClass, String attribute) { DatabaseMapping mapping = resolveAttributeMapping(ownerClass, attribute); return (mapping != null) && mapping.isForeignReferenceMapping(); }
/** * INTERNAL: * Add the provided object to the deleted objects list on the commit manager. * This may be overridden by subclasses to process a composite object * * @see MappedKeyMapContainerPolicy * @param object * @param manager */ public void postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow){ if (mapping.isForeignReferenceMapping()){ Object clone = ocs.getUnitOfWorkClone(); uow.addDeletedPrivateOwnedObjects(mapping, clone); } }
public void setKeyMapping(MapKeyMapping mapping){ if (((DatabaseMapping)mapping).isForeignReferenceMapping() && ((ForeignReferenceMapping)mapping).getIndirectionPolicy().usesIndirection()){ throw ValidationException.mapKeyCannotUseIndirection((DatabaseMapping)mapping); } this.keyMapping = mapping; ((DatabaseMapping)mapping).setIsMapKeyMapping(true); }
public void setKeyMapping(MapKeyMapping mapping){ if (((DatabaseMapping)mapping).isForeignReferenceMapping() && ((ForeignReferenceMapping)mapping).getIndirectionPolicy().usesIndirection()){ throw ValidationException.mapKeyCannotUseIndirection((DatabaseMapping)mapping); } this.keyMapping = mapping; ((DatabaseMapping)mapping).setIsMapKeyMapping(true); }
public void setKeyMapping(MapKeyMapping mapping){ if (((DatabaseMapping)mapping).isForeignReferenceMapping() && ((ForeignReferenceMapping)mapping).getIndirectionPolicy().usesIndirection()){ throw ValidationException.mapKeyCannotUseIndirection((DatabaseMapping)mapping); } this.keyMapping = mapping; ((DatabaseMapping)mapping).setIsMapKeyMapping(true); }
/** * Is the attribute an association. * @return whether boolean indicating whether attribute * corresponds to an association */ public boolean isAssociation() { // If the mapping a relationship to another entity. return getMapping().isForeignReferenceMapping() && !getMapping().isDirectCollectionMapping() && !getMapping().isAggregateCollectionMapping(); }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ protected void mergeClientIntoServerValueHolder(RemoteValueHolder serverValueHolder, MergeManager mergeManager) { serverValueHolder.setMapping(this.mapping); serverValueHolder.setSession(mergeManager.getSession()); if (this.mapping.isForeignReferenceMapping()) { ObjectLevelReadQuery query = buildCascadeQuery(mergeManager); serverValueHolder.setQuery(query); } }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ protected void mergeClientIntoServerValueHolder(RemoteValueHolder serverValueHolder, MergeManager mergeManager) { serverValueHolder.setMapping(this.mapping); serverValueHolder.setSession(mergeManager.getSession()); if (this.mapping.isForeignReferenceMapping()) { ObjectLevelReadQuery query = buildCascadeQuery(mergeManager); serverValueHolder.setQuery(query); } }
/** * INTERNAL: * Add the provided object to the deleted objects list on the commit manager. * This may be overridden by subclasses to process a composite object. */ @Override public void postCalculateChanges(Object key, Object value, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow) { if (((DatabaseMapping)getKeyMapping()).isForeignReferenceMapping() && ((DatabaseMapping)getKeyMapping()).isPrivateOwned()) { uow.addDeletedPrivateOwnedObjects((DatabaseMapping)getKeyMapping(), key); } super.postCalculateChanges(key, value, referenceDescriptor, mapping, uow); }
/** * INTERNAL: * Add the provided object to the deleted objects list on the commit manager. * This may be overridden by subclasses to process a composite object. */ @Override public void postCalculateChanges(Object key, Object value, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow) { if (((DatabaseMapping)getKeyMapping()).isForeignReferenceMapping() && ((DatabaseMapping)getKeyMapping()).isPrivateOwned()) { uow.addDeletedPrivateOwnedObjects((DatabaseMapping)getKeyMapping(), key); } super.postCalculateChanges(key, value, referenceDescriptor, mapping, uow); }
/** * INTERNAL: * This method is used to store the FK fields that can be cached that correspond to noncacheable mappings * the FK field values will be used to re-issue the query when cloning the shared cache entity */ @Override public void collectQueryParameters(Set<DatabaseField> record){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()){ if ((mapping.isForeignReferenceMapping() && !mapping.isCacheable()) || (mapping.isAggregateObjectMapping() && mapping.getReferenceDescriptor().hasNoncacheableMappings())){ ((ForeignReferenceMapping) mapping).collectQueryParameters(record); } } }
/** * INTERNAL: * This method is used to store the FK fields that can be cached that correspond to noncacheable mappings * the FK field values will be used to re-issue the query when cloning the shared cache entity */ @Override public void collectQueryParameters(Set<DatabaseField> record){ for (DatabaseMapping mapping : getReferenceDescriptor().getMappings()){ if ((mapping.isForeignReferenceMapping() && !mapping.isCacheable()) || (mapping.isAggregateObjectMapping() && mapping.getReferenceDescriptor().hasNoncacheableMappings())){ ((ForeignReferenceMapping) mapping).collectQueryParameters(record); } } }
/** * INTERNAL * Replace the client value holder with the server value holder, * after copying some of the settings from the client value holder. */ protected void mergeClientIntoServerValueHolder(RemoteValueHolder serverValueHolder, MergeManager mergeManager) { serverValueHolder.setMapping(getMapping()); serverValueHolder.setSession(mergeManager.getSession()); if (getMapping().isForeignReferenceMapping()) { ObjectLevelReadQuery query = buildCascadeQuery(mergeManager); serverValueHolder.setQuery(query); } }
/** * INTERNAL: * Add the provided object to the deleted objects list on the commit manager. * This may be overridden by subclasses to process a composite object. */ @Override public void postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow) { if (((DatabaseMapping)getKeyMapping()).isForeignReferenceMapping() && ((DatabaseMapping)getKeyMapping()).isPrivateOwned()) { Object key = ocs.getOldKey(); uow.addDeletedPrivateOwnedObjects((DatabaseMapping)getKeyMapping(), key); } super.postCalculateChanges(ocs, referenceDescriptor, mapping, uow); }
/** * INTERNAL: * Add the provided object to the deleted objects list on the commit manager. * This may be overridden by subclasses to process a composite object. */ @Override public void postCalculateChanges(ObjectChangeSet ocs, ClassDescriptor referenceDescriptor, DatabaseMapping mapping, UnitOfWorkImpl uow) { if (((DatabaseMapping)getKeyMapping()).isForeignReferenceMapping() && ((DatabaseMapping)getKeyMapping()).isPrivateOwned()) { Object key = ocs.getOldKey(); uow.addDeletedPrivateOwnedObjects((DatabaseMapping)getKeyMapping(), key); } super.postCalculateChanges(ocs, referenceDescriptor, mapping, uow); }
protected void initNonReferenceEntityFetchGroup() { FetchGroup nonReferenceFetchGroup = new FetchGroup(); for (DatabaseMapping mapping : getDescriptor().getMappings()) { if(!mapping.isForeignReferenceMapping()) { String name = mapping.getAttributeName(); if(this.defaultEntityFetchGroup == null || this.defaultEntityFetchGroup.containsAttribute(name)) { nonReferenceFetchGroup.addAttribute(name); } } } this.addMinimalFetchGroup(nonReferenceFetchGroup); this.nonReferenceEntityFetchGroup = getEntityFetchGroup(nonReferenceFetchGroup); }
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }
protected void initNonReferenceEntityFetchGroup() { FetchGroup nonReferenceFetchGroup = new FetchGroup(); for (DatabaseMapping mapping : getDescriptor().getMappings()) { if(!mapping.isForeignReferenceMapping()) { String name = mapping.getAttributeName(); if(this.defaultEntityFetchGroup == null || this.defaultEntityFetchGroup.containsAttribute(name)) { nonReferenceFetchGroup.addAttribute(name); } } } this.addMinimalFetchGroup(nonReferenceFetchGroup); this.nonReferenceEntityFetchGroup = getEntityFetchGroup(nonReferenceFetchGroup); }
private Property buildProperty(PersistenceContext context, DatabaseMapping mapping) { if (mapping.isCollectionMapping()) { final Property property = new Property(); property.setType("array"); property.setItems(buildProperty(context, getCollectionGenericClass(mapping))); return property; } else if (mapping.isForeignReferenceMapping()) { final ForeignReferenceMapping foreignReferenceMapping = (ForeignReferenceMapping)mapping; final String href = HrefHelper.buildEntityMetadataHref(context, foreignReferenceMapping.getReferenceClass().getSimpleName() + "#"); return new Property(href); } else { return buildProperty(context, mapping.getAttributeClassification()); } }