/** Returns true if the specified type denotes an embedded attribute. */ public boolean isEmbeddedAttribute(Object ownerClass, String attribute) { DatabaseMapping mapping = resolveAttributeMapping(ownerClass, attribute); return (mapping != null) && mapping.isAggregateMapping(); }
/** * Return if the attribute is specified for joining. */ public boolean isAttributeJoined(ClassDescriptor mappingDescriptor, DatabaseMapping attributeMapping) { // Since aggregates share the same query as their parent, must avoid the aggregate thinking // the parents mappings is for it, (queries only share if the aggregate was not joined). //This isn't taking into account inheritance - a query on a child may use/join parent level mappings if (this.hasJoinedAttributes()) { //if it has joined attributes, the other collections must also be set and so don't need to be checked if (attributeMapping.isAggregateMapping()){ return this.getJoinedAggregateMappings().contains(attributeMapping); } else { return this.getJoinedAttributeMappings().contains(attributeMapping); }} return isAttributeExpressionJoined(attributeMapping) || isAttributeMappingJoined(attributeMapping); }
/** * Return if the attribute is specified for joining. */ public boolean isAttributeJoined(ClassDescriptor mappingDescriptor, DatabaseMapping attributeMapping) { // Since aggregates share the same query as their parent, must avoid the aggregate thinking // the parents mappings is for it, (queries only share if the aggregate was not joined). //This isn't taking into account inheritance - a query on a child may use/join parent level mappings if (this.hasJoinedAttributes()) { //if it has joined attributes, the other collections must also be set and so don't need to be checked if (attributeMapping.isAggregateMapping()){ return this.getJoinedAggregateMappings().contains(attributeMapping); } else { return this.getJoinedAttributeMappings().contains(attributeMapping); }} return isAttributeExpressionJoined(attributeMapping) || isAttributeMappingJoined(attributeMapping); }
protected Expression resolveBaseExpression(Expression expression) { Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); //filter out aggregate expressions between this and the next node. while (!baseExpression.isExpressionBuilder() && ((QueryKeyExpression)baseExpression).getMapping().isAggregateMapping()){ baseExpression = ((BaseExpression)baseExpression).getBaseExpression(); } return baseExpression; }
Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); while (!baseExpression.isExpressionBuilder() && ((QueryKeyExpression)baseExpression).getMapping().isAggregateMapping()){ baseExpression = ((BaseExpression)baseExpression).getBaseExpression();
Expression baseExpression = ((BaseExpression)expression).getBaseExpression(); while (!baseExpression.isExpressionBuilder() && ((QueryKeyExpression)baseExpression).getMapping().isAggregateMapping()){ baseExpression = ((BaseExpression)baseExpression).getBaseExpression();
/** * 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; }
/** */ private Object getType(DatabaseMapping mapping) { if (mapping == null) { return null; } Object type = null; if (mapping.isDirectCollectionMapping()){ type = ((DirectCollectionMapping)mapping).getDirectField().getType(); if (type == null){ type = BasicTypeHelperImpl.ElementPlaceHolder.class; } } else if (mapping.isForeignReferenceMapping()) { ClassDescriptor descriptor = mapping.getReferenceDescriptor(); type = descriptor == null ? null : descriptor.getJavaClass(); } else if (mapping.isAggregateMapping()) { // Return the ClassDescriptor as the type representation in case // of an embedded. This makes sure that any property or field // access of the embedded uses the correct mapping information and // not the shell of the descriptors as stored by the session. type = ((AggregateMapping)mapping).getReferenceDescriptor(); } else { type = mapping.getAttributeAccessor().getAttributeClass(); } return type; }
if (mapping.isAggregateMapping()) { ClassDescriptor descriptor = ((AggregateMapping) mapping).getReferenceDescriptor(); if (descriptor != null) {
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
/** * INTERNAL: * Configure all descriptors referencing this class to be protected and update their cache settings. */ public void notifyReferencingDescriptorsOfIsolation(AbstractSession session) { for (ClassDescriptor descriptor : this.referencingClasses){ if (descriptor.getCachePolicy().getCacheIsolation() == null || descriptor.getCachePolicy().getCacheIsolation() == CacheIsolationType.SHARED) { descriptor.getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); descriptor.getCachePolicy().postInitialize(descriptor, session); for (DatabaseMapping mapping : descriptor.getMappings()) { if (mapping.isAggregateMapping() && (mapping.getReferenceDescriptor() != null)) { mapping.getReferenceDescriptor().getCachePolicy().setCacheIsolation(CacheIsolationType.PROTECTED); } } } } }
ClassDescriptor descriptor = mapping.getReferenceDescriptor(); type = descriptor == null ? null : descriptor.getJavaClass(); } else if (mapping.isAggregateMapping()) {
private Object getType(DatabaseMapping mapping) { if (mapping == null) { return null; } Object type = null; if (mapping.isDirectCollectionMapping()){ type = ((DirectCollectionMapping)mapping).getDirectField().getType(); if (type == null){ type = Object.class; } } else if (mapping.isAggregateCollectionMapping()) { // Return the ClassDescriptor as the type representation in case // of an embedded. This makes sure that any property or field // access of the embedded uses the correct mapping information and // not the shell of the descriptors as stored by the session. type = ((AggregateCollectionMapping)mapping).getReferenceDescriptor(); } else if (mapping.isForeignReferenceMapping()) { ClassDescriptor descriptor = mapping.getReferenceDescriptor(); type = descriptor == null ? null : descriptor.getJavaClass(); } else if (mapping.isAggregateMapping()) { // Return the ClassDescriptor as the type representation in case // of an embedded. This makes sure that any property or field // access of the embedded uses the correct mapping information and // not the shell of the descriptors as stored by the session. type = ((AggregateMapping)mapping).getReferenceDescriptor(); } else { type = mapping.getAttributeAccessor().getAttributeClass(); } return type; }
if (mapping.isAggregateMapping()) { Object nestedObject = mapping.getRealAttributeValueFromObject(nestedKeyInstance, session); if (nestedObject == null) {
if (mapping.isAggregateMapping()) { Object nestedObject = mapping.getRealAttributeValueFromObject(keyInstance, session);
/** * INTERNAL: * Recursive method to set a field value in the given key instance. */ protected void setFieldValue(KeyElementAccessor accessor, Object keyInstance, DatabaseMapping mapping, AbstractSession session, int[] elementIndex, Object ... keyElements) { if (mapping.isAggregateMapping()) { Object nestedObject = mapping.getRealAttributeValueFromObject(keyInstance, session); if (nestedObject == null) { nestedObject = getClassInstance(mapping.getReferenceDescriptor().getJavaClass()); mapping.setRealAttributeValueInObject(keyInstance, nestedObject); } // keep drilling down the nested mappings ... setFieldValue(accessor, nestedObject, mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(accessor.getDatabaseField()), session, elementIndex, keyElements); } else { Object fieldValue = null; if (mapping.isAbstractColumnMapping()) { fieldValue = keyElements[elementIndex[0]]; Converter converter = ((AbstractColumnMapping) mapping).getConverter(); if (converter != null){ fieldValue = converter.convertDataValueToObjectValue(fieldValue, session); } ++elementIndex[0]; } else if (mapping.isObjectReferenceMapping()) { // what if mapping comes from derived ID. need to get the derived mapping. // get reference descriptor and extract pk from target cmp policy fieldValue = mapping.getReferenceDescriptor().getCMPPolicy().createPrimaryKeyInstanceFromPrimaryKeyValues(session, elementIndex, keyElements); } accessor.setValue(keyInstance, fieldValue); } }
throw QueryException.invalidExpressionForQueryItem(this, query); } else if (mapping.isAggregateMapping()) { descriptor = ((AggregateMapping)mapping).getReferenceDescriptor(); } else if (mapping.isForeignReferenceMapping()) {
throw QueryException.invalidExpressionForQueryItem(this, query); } else if (mapping.isAggregateMapping()) { descriptor = ((AggregateMapping)mapping).getReferenceDescriptor(); } else if (mapping.isForeignReferenceMapping()) {
} else { if (mapping.isAggregateMapping()) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(accessor.getDatabaseField());
} else { if (mapping.isAggregateMapping()) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForField(accessor.getDatabaseField());