/** * INTERNAL: * If a user does not specify the target key then the primary keys of the target table are used. */ protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getReferenceDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getTargetKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * INTERNAL: * If a user does not specify the target key then the primary keys of the target table are used. */ protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getReferenceDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getTargetKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * INTERNAL: * If a user does not specify the target key then the primary keys of the target table are used. */ protected void initializeTargetKeysWithDefaults(AbstractSession session, ForeignReferenceMapping mapping) { List<DatabaseField> primaryKeyFields = mapping.getReferenceDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { getTargetKeyFields().addElement(primaryKeyFields.get(index)); } }
/** * INTERNAL: * Add to a row target relation fields with values extracted from the target object. */ public AbstractRecord addRelationTableTargetRow(Object targetObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) { ObjectBuilder builder = mapping.getReferenceDescriptor().getObjectBuilder(); int size = targetKeyFields.size(); for(int i=0; i < size; i++) { Object sourceValue = builder.extractValueFromObjectForField(targetObject, targetKeyFields.get(i), session); databaseRow.put(targetRelationKeyFields.get(i), sourceValue); } return databaseRow; }
/** * INTERNAL: * Add to a row target relation fields with values extracted from the target object. */ public AbstractRecord addRelationTableTargetRow(Object targetObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) { ObjectBuilder builder = mapping.getReferenceDescriptor().getObjectBuilder(); int size = targetKeyFields.size(); for(int i=0; i < size; i++) { Object sourceValue = builder.extractValueFromObjectForField(targetObject, targetKeyFields.get(i), session); databaseRow.put(targetRelationKeyFields.get(i), sourceValue); } return databaseRow; }
/** * INTERNAL: * Add to a row target relation fields with values extracted from the target object. */ public AbstractRecord addRelationTableTargetRow(Object targetObject, AbstractSession session, AbstractRecord databaseRow, ForeignReferenceMapping mapping) { ObjectBuilder builder = mapping.getReferenceDescriptor().getObjectBuilder(); int size = targetKeyFields.size(); for(int i=0; i < size; i++) { Object sourceValue = builder.extractValueFromObjectForField(targetObject, targetKeyFields.get(i), session); databaseRow.put(targetRelationKeyFields.get(i), sourceValue); } return databaseRow; }
/** * INTERNAL: * All the target key field names are converted to DatabaseField and stored. */ protected void initializeTargetKeys(AbstractSession session, ForeignReferenceMapping mapping) { for (int index = 0; index < getTargetKeyFields().size(); index++) { DatabaseField field = mapping.getReferenceDescriptor().buildField(getTargetKeyFields().get(index)); getTargetKeyFields().set(index, field); } }
/** * INTERNAL: * All the target key field names are converted to DatabaseField and stored. */ protected void initializeTargetKeys(AbstractSession session, ForeignReferenceMapping mapping) { for (int index = 0; index < getTargetKeyFields().size(); index++) { DatabaseField field = mapping.getReferenceDescriptor().buildField(getTargetKeyFields().get(index)); getTargetKeyFields().set(index, field); } }
/** * INTERNAL: * All the target key field names are converted to DatabaseField and stored. */ protected void initializeTargetKeys(AbstractSession session, ForeignReferenceMapping mapping) { for (int index = 0; index < getTargetKeyFields().size(); index++) { DatabaseField field = mapping.getReferenceDescriptor().buildField(getTargetKeyFields().get(index)); getTargetKeyFields().set(index, field); } }
/** * INTERNAL: * Return the relationshipPartner mapping for this bi-directional mapping. If the relationshipPartner is null then * this is a uni-directional mapping. */ @Override public DatabaseMapping getRelationshipPartner() { if ((this.relationshipPartner == null) && (this.relationshipPartnerAttributeName != null)) { setRelationshipPartner(getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(getRelationshipPartnerAttributeName())); } return this.relationshipPartner; }
/** * INTERNAL: * Return the relationshipPartner mapping for this bi-directional mapping. If the relationshipPartner is null then * this is a uni-directional mapping. */ public DatabaseMapping getRelationshipPartner() { if ((this.relationshipPartner == null) && (this.relationshipPartnerAttributeName != null)) { setRelationshipPartner(getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(getRelationshipPartnerAttributeName())); } return this.relationshipPartner; }
/** * INTERNAL: * Return the relationshipPartner mapping for this bi-directional mapping. If the relationshipPartner is null then * this is a uni-directional mapping. */ public DatabaseMapping getRelationshipPartner() { if ((this.relationshipPartner == null) && (this.relationshipPartnerAttributeName != null)) { setRelationshipPartner(getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(getRelationshipPartnerAttributeName())); } return this.relationshipPartner; }
/** * INTERNAL: * Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity. This is * used when an Entity is merged into itself and the Entity reference new or detached entities. */ public void updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork){ Map<ObjectChangeSet, ObjectChangeSet> list = ((CollectionChangeRecord)changeRecord).getAddObjectList(); ObjectChangeSet sourceSet = parentUOWChangeSet.getCloneToObjectChangeSet().get(source); if (list.containsKey(sourceSet)){ ObjectChangeSet targetSet = ((UnitOfWorkChangeSet)unitOfWork.getUnitOfWorkChangeSet()).findOrCreateLocalObjectChangeSet(target, mapping.getReferenceDescriptor(), unitOfWork.isCloneNewObject(target)); targetSet.setNewKey(sourceSet.getNewKey()); targetSet.setOldKey(sourceSet.getOldKey()); parentUOWChangeSet.addObjectChangeSetForIdentity(targetSet, target); list.remove(sourceSet); list.put(targetSet, targetSet); return; } }
/** * INTERNAL: * Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity. This is * used when an Entity is merged into itself and the Entity reference new or detached entities. */ @Override public void updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork){ ObjectChangeSet sourceSet = parentUOWChangeSet.getCloneToObjectChangeSet().get(source); for (OrderedChangeObject changeObject : ((CollectionChangeRecord)changeRecord).getOrderedChangeObjectList()){ if (changeObject.getChangeSet() == sourceSet){ changeObject.setChangeSet(((UnitOfWorkChangeSet)unitOfWork.getUnitOfWorkChangeSet()).findOrCreateLocalObjectChangeSet(target, mapping.getReferenceDescriptor(), unitOfWork.isCloneNewObject(target))); } return; } }
/** * INTERNAL: * Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity. This is * used when an Entity is merged into itself and the Entity reference new or detached entities. */ @Override public void updateChangeRecordForSelfMerge(ChangeRecord changeRecord, Object source, Object target, ForeignReferenceMapping mapping, UnitOfWorkChangeSet parentUOWChangeSet, UnitOfWorkImpl unitOfWork){ ObjectChangeSet sourceSet = parentUOWChangeSet.getCloneToObjectChangeSet().get(source); for (OrderedChangeObject changeObject : ((CollectionChangeRecord)changeRecord).getOrderedChangeObjectList()){ if (changeObject.getChangeSet() == sourceSet){ changeObject.setChangeSet(((UnitOfWorkChangeSet)unitOfWork.getUnitOfWorkChangeSet()).findOrCreateLocalObjectChangeSet(target, mapping.getReferenceDescriptor(), unitOfWork.isCloneNewObject(target))); } return; } }
/** * Force instantiation of the load group. */ @Override public void load(final Object object, AttributeItem item, final AbstractSession session, final boolean fromFetchGroup) { instantiateAttribute(object, session); if (item.getGroup() != null && (!fromFetchGroup || session.isUnitOfWork())) { // if fromFetchGroup then the above instantiate already loaded the elements unless this is in UOW // in which case the clones must be loaded as well. Object value = getRealAttributeValueFromObject(object, session); session.load(value, item.getGroup(), getReferenceDescriptor(), fromFetchGroup); } }
/** * Force instantiation of the load group. */ @Override public void load(final Object object, AttributeItem item, final AbstractSession session, final boolean fromFetchGroup) { instantiateAttribute(object, session); if (item.getGroup() != null && (!fromFetchGroup || session.isUnitOfWork())) { // if fromFetchGroup then the above instantiate already loaded the elements unless this is in UOW // in which case the clones must be loaded as well. Object value = getRealAttributeValueFromObject(object, session); session.load(value, item.getGroup(), getReferenceDescriptor(), fromFetchGroup); } }
/** * A subclass should implement this method if it wants non default behavior. */ protected void initializeSelectionQuery(AbstractSession session) throws DescriptorException { if (((ObjectLevelReadQuery)getSelectionQuery()).getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } getSelectionQuery().setName(getAttributeName()); getSelectionQuery().setDescriptor(getReferenceDescriptor()); getSelectionQuery().setSourceMapping(this); }
/** * A subclass should implement this method if it wants non default behavior. */ protected void initializeSelectionQuery(AbstractSession session) throws DescriptorException { if (((ObjectLevelReadQuery)getSelectionQuery()).getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } getSelectionQuery().setName(getAttributeName()); getSelectionQuery().setDescriptor(getReferenceDescriptor()); getSelectionQuery().setSourceMapping(this); if (getSelectionQuery().getPartitioningPolicy() == null) { getSelectionQuery().setPartitioningPolicy(getPartitioningPolicy()); } }
/** * A subclass should implement this method if it wants non default behavior. */ protected void initializeSelectionQuery(AbstractSession session) throws DescriptorException { if (((ObjectLevelReadQuery)getSelectionQuery()).getReferenceClass() == null) { throw DescriptorException.referenceClassNotSpecified(this); } getSelectionQuery().setName(getAttributeName()); getSelectionQuery().setDescriptor(getReferenceDescriptor()); getSelectionQuery().setSourceMapping(this); if (getSelectionQuery().getPartitioningPolicy() == null) { getSelectionQuery().setPartitioningPolicy(getPartitioningPolicy()); } }