/** * Process against the UOW and attempt to load a local copy before going to the shared cache * If null is returned then the calling UOW will instantiate as normal. */ @Override public Object getValue(UnitOfWorkImpl uow) { if (this.references != null && this.references.length != 0){ if (mapping.isCollectionMapping()){ Collection result = uow.getIdentityMapAccessorInstance().getAllFromIdentityMapWithEntityPK(this.references, this.mapping.getReferenceDescriptor()).values(); if (result.size() == references.length){ ContainerPolicy cp = mapping.getContainerPolicy(); Object container = cp.containerInstance(result.size()); for (Object object : result){ cp.addInto(object, container, uow); } return container; } }else{ return uow.getIdentityMapAccessorInstance().getFromIdentityMap(this.references[0], this.mapping.getReferenceClass()); } } return null; }
/** * Process against the UOW and attempt to load a local copy before going to the shared cache * If null is returned then the calling UOW will instantiate as normal. */ @Override public Object getValue(UnitOfWorkImpl uow) { if (this.references != null && this.references.length != 0){ if (mapping.isCollectionMapping()){ Collection result = uow.getIdentityMapAccessorInstance().getAllFromIdentityMapWithEntityPK(this.references, this.mapping.getReferenceDescriptor()).values(); if (result.size() == references.length){ ContainerPolicy cp = mapping.getContainerPolicy(); Object container = cp.containerInstance(result.size()); for (Object object : result){ cp.addInto(object, container, uow); } return container; } }else{ return uow.getIdentityMapAccessorInstance().getFromIdentityMap(this.references[0], this.mapping.getReferenceClass()); } } return null; }
/** * Test if a mapping requires initialization when a new instance is created. * This is true for: * <ul> * <li>primitives * <li>collection mappings * <li>basic indirection references * </ul> * * @see DynamicHelper#newDynamicEntity for creation and initialization */ private boolean requiresInitialization(DatabaseMapping mapping) { if (mapping.isDirectToFieldMapping() && mapping.getAttributeClassification() != null && mapping.getAttributeClassification().isPrimitive()) { return true; } if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; return frMapping.usesIndirection() || frMapping.isCollectionMapping(); } if (mapping.isAggregateObjectMapping() && !mapping.isXMLMapping()) { return !((AggregateObjectMapping) mapping).isNullAllowed(); } return false; }
/** * Test if a mapping requires initialization when a new instance is created. * This is true for: * <ul> * <li>primitives * <li>collection mappings * <li>basic indirection references * </ul> * * @see #newDynamicEntity() for creation and initialization */ private boolean requiresInitialization(DatabaseMapping mapping) { if (mapping.isDirectToFieldMapping() && mapping.getAttributeClassification() != null && mapping.getAttributeClassification().isPrimitive()) { return true; } if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; return frMapping.usesIndirection() || frMapping.isCollectionMapping(); } if (mapping.isAggregateMapping() && !mapping.isXMLMapping()) { return !((AggregateObjectMapping) mapping).isNullAllowed(); } return false; }
/** * Test if a mapping requires initialization when a new instance is created. * This is true for: * <ul> * <li>primitives * <li>collection mappings * <li>basic indirection references * </ul> * * @see DynamicHelper#newDynamicEntity for creation and initialization */ private boolean requiresInitialization(DatabaseMapping mapping) { if (mapping.isDirectToFieldMapping() && mapping.getAttributeClassification() != null && mapping.getAttributeClassification().isPrimitive()) { return true; } if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping frMapping = (ForeignReferenceMapping) mapping; return frMapping.usesIndirection() || frMapping.isCollectionMapping(); } if (mapping.isAggregateObjectMapping() && !mapping.isXMLMapping()) { return !((AggregateObjectMapping) mapping).isNullAllowed(); } return false; }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
@Override public Class<?> getAttributeClass() { if (mapping.isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping)mapping; if (refMapping.isCollectionMapping()) { return ((CollectionMapping)refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (mapping.getAttributeClassification() == null) { return ClassConstants.OBJECT; } return mapping.getAttributeClassification(); } } }
if(mapping.isCollectionMapping()) { relationKeyEnum = getTargetRelationKeyFields().elements(); for (; relationKeyEnum.hasMoreElements();) {
joinRow.put((DatabaseField)sourceEnum.nextElement(), null); if(mapping.isCollectionMapping()) { CollectionMapping collectionMapping = (CollectionMapping)mapping; if(collectionMapping.getListOrderField() != null) {
@Override public Class<?> getAttributeClass() { if (getMapping().isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping) getMapping(); if (refMapping.isCollectionMapping()) { return ((CollectionMapping) refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (getMapping().getAttributeClassification() == null) { return ClassConstants.OBJECT; } return getMapping().getAttributeClassification(); } } }
if (mapping.isCollectionMapping()){ ((CollectionMapping)mapping).getContainerPolicy().addNestedJoinsQueriesForMapKey(this, readQuery, session);
if (mapping.isCollectionMapping()) { ((CollectionMapping)mapping).getContainerPolicy().initialize(session, getRelationTable());
/** * Add the mapping join fetch. */ public void addJoinedMapping(ForeignReferenceMapping mapping) { if (mapping.isCollectionMapping()) { Expression joinMappingExpression = null; if (mapping.isInnerJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOf(mapping.getAttributeName()); } else if (mapping.isOuterJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOfAllowingNone(mapping.getAttributeName()); } if(joinMappingExpression != null) { addJoinedMappingExpression(joinMappingExpression); if(((CollectionMapping)mapping).getListOrderField() != null) { Expression expField = ((CollectionMapping)mapping).getListOrderFieldExpression(joinMappingExpression); getAdditionalFieldExpressions().add(expField); } } } else { if (mapping.isInnerJoinFetched()) { addJoinedMappingExpression(getBaseExpressionBuilder().get(mapping.getAttributeName())); } else if (mapping.isOuterJoinFetched()) { addJoinedMappingExpression(getBaseExpressionBuilder().getAllowingNull(mapping.getAttributeName())); } } }
if(mapping.isCollectionMapping()) { ((CollectionMapping)mapping).getContainerPolicy().initialize(session, getRelationTable());
if (mapping.isCollectionMapping()) { ((CollectionMapping)mapping).getContainerPolicy().initialize(session, getRelationTable());
/** * Add the mapping for join fetch, prepare and return the join expression being used. */ public Expression addAndPrepareJoinedMapping(ForeignReferenceMapping mapping, AbstractSession session) { Expression joinMappingExpression = null; if (mapping.isCollectionMapping()) { if (mapping.isInnerJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOf(mapping.getAttributeName(), false); } else if (mapping.isOuterJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOfAllowingNone(mapping.getAttributeName(), false); } } else { if (mapping.isInnerJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().get(mapping.getAttributeName()); } else if (mapping.isOuterJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().getAllowingNull(mapping.getAttributeName()); } } if (joinMappingExpression != null) { joinMappingExpression = prepareJoinExpression(joinMappingExpression, session); addJoinedMappingExpression(joinMappingExpression); } return joinMappingExpression; }
/** * Add the mapping for join fetch, prepare and return the join expression being used. */ public Expression addAndPrepareJoinedMapping(ForeignReferenceMapping mapping, AbstractSession session) { Expression joinMappingExpression = null; if (mapping.isCollectionMapping()) { if (mapping.isInnerJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOf(mapping.getAttributeName(), false); } else if (mapping.isOuterJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().anyOfAllowingNone(mapping.getAttributeName(), false); } } else { if (mapping.isInnerJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().get(mapping.getAttributeName()); } else if (mapping.isOuterJoinFetched()) { joinMappingExpression = getBaseExpressionBuilder().getAllowingNull(mapping.getAttributeName()); } } if (joinMappingExpression != null) { joinMappingExpression = prepareJoinExpression(joinMappingExpression, session); addJoinedMappingExpression(joinMappingExpression); } return joinMappingExpression; }
if (mapping.isCollectionMapping()) { for (DatabaseField relationKey : getTargetRelationKeyFields()) { Expression expression = builder.getField(relationKey).equal(builder.getParameter(relationKey));
joinRow.put(field, null); if (mapping.isCollectionMapping()) { CollectionMapping collectionMapping = (CollectionMapping)mapping; if (collectionMapping.getListOrderField() != null) {
joinRow.put(field, null); if (mapping.isCollectionMapping()) { CollectionMapping collectionMapping = (CollectionMapping)mapping; if (collectionMapping.getListOrderField() != null) {