/** * INTERNAL: */ public boolean hasMappingForAttributeName(String attributeName) { return m_descriptor.getMappingForAttributeName(attributeName) != null; }
/** * ADVANCED: * Removes the locally defined mapping associated with a given attribute name. * This can be used in a amendment method before the descriptor has been initialized. */ public DatabaseMapping removeMappingForAttributeName(String attributeName) { DatabaseMapping mapping = getMappingForAttributeName(attributeName); getMappings().remove(mapping); return mapping; }
/** Returns the mapping for the specified attribute of the psecified * class. The method returns null if the class is not known or if the * class does not have an attribute of the specified name. */ private DatabaseMapping resolveAttributeMapping(Object ownerClass, String attr) { ClassDescriptor desc = getDescriptor(ownerClass); return (desc == null) ? null : desc.getMappingForAttributeName(attr); }
/** * 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().getMappingForAttributeName(getRelationshipPartnerAttributeName())); } return this.relationshipPartner; }
/** * resolveMapping: Answer the mapping which corresponds to my variableName. */ public DatabaseMapping resolveMapping(GenerationContext context, Class ownerClass) { ClassDescriptor descriptor = context.getSession().getDescriptor(ownerClass); return (descriptor==null) ? null : descriptor.getMappingForAttributeName(getAttributeName()); }
/** * INTERNAL: * This method is for processing a single FieldResult, returning the DatabaseField it refers to. */ public DatabaseField processValueFromRecordForMapping(ClassDescriptor descriptor, String[] attributeNames, int currentLoc){ DatabaseMapping mapping = descriptor.getMappingForAttributeName(attributeNames[currentLoc]); if (mapping==null){throw QueryException.mappingForFieldResultNotFound(attributeNames,currentLoc);} currentLoc++; if (attributeNames.length!=currentLoc){ ClassDescriptor currentDescriptor = mapping.getReferenceDescriptor(); DatabaseField df= processValueFromRecordForMapping(currentDescriptor, attributeNames, currentLoc); if (mapping.isOneToOneMapping()){ return (DatabaseField)(((OneToOneMapping)mapping).getTargetToSourceKeyFields().get(df)); } return df; }else{ //this is it.. return this mapping's field return (DatabaseField) mapping.getFields().firstElement(); } }
/** * INTERNAL: * Lookup the mapping for this item by traversing its expression recursively. * If an aggregate of foreign mapping is found it is traversed. */ public DatabaseMapping getLeafMappingFor(Expression expression, ClassDescriptor rootDescriptor) throws QueryException { // Check for database field expressions or place holder if ((expression == null) || (expression.isFieldExpression())) { return null; } if (!(expression.isQueryKeyExpression())) { return null; } QueryKeyExpression qkExpression = (QueryKeyExpression)expression; Expression baseExpression = qkExpression.getBaseExpression(); ClassDescriptor descriptor = getLeafDescriptorFor(baseExpression, rootDescriptor); return descriptor.getMappingForAttributeName(qkExpression.getName()); }
/** * Helper method to retrieve the relationship partner mapping. This will take inheritance * into account and return the mapping associated with correct subclass if necessary. This * is needed for EJB 2.0 inheritance */ private ForeignReferenceMapping getRelationshipPartnerFor(Object partnerObject) { ForeignReferenceMapping partner = (ForeignReferenceMapping)getMapping().getRelationshipPartner(); if ((partner == null) || (partnerObject == null)) { // no partner, nothing to do return partner; } // if the target object is not an instance of the class type associated with the partner // mapping, try and look up the same partner mapping but as part of the partnerObject's // descriptor. Only check if inheritance is involved... if (partner.getDescriptor().hasInheritance()) { ClassDescriptor partnerObjectDescriptor = this.getSession().getDescriptor(partnerObject); if (!(partner.getDescriptor().getJavaClass().isAssignableFrom(partnerObjectDescriptor.getJavaClass()))) { return (ForeignReferenceMapping)partnerObjectDescriptor.getMappingForAttributeName(partner.getAttributeName()); } } return partner; } }
/** * PUBLIC: * Re-populate the database row with the values from the source object based upon the * attribute's mapping. Provided as a helper method for modifying the row during event * handling. */ public void applyAttributeValuesIntoRow(String attributeName) { ClassDescriptor descriptor = getSession().getDescriptor(getSource()); DatabaseMapping mapping = descriptor.getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession()); } }
DatabaseMapping mapping = descriptor.getMappingForAttributeName((String)joinManager.getJoinedAttributes().get(index)); if (mapping !=null){ Object attributeValue = mapping.getRealAttributeValueFromObject(clone, unitOfWork);
return m_descriptor.getMappingForAttributeName(attributeName);
String attributeName = expression.getName(); DatabaseMapping mapping = baseDescriptor.getMappingForAttributeName(attributeName);
DatabaseMapping mapping = this.query.getDescriptor().getMappingForAttributeName(attributeName); if (mapping == null) { throw DescriptorException.mappingForAttributeIsMissing(attributeName, getDescriptor());
DatabaseMapping mapping = this.query.getDescriptor().getMappingForAttributeName(attributeName); if (mapping == null) { throw DescriptorException.mappingForAttributeIsMissing(attributeName, getDescriptor());
DatabaseMapping mapping = this.query.getDescriptor().getMappingForAttributeName(attributeName); if (mapping == null) { throw DescriptorException.mappingForAttributeIsMissing(attributeName, getDescriptor());
DatabaseMapping mapping = descriptor.getMappingForAttributeName(((QueryKeyExpression)getFirstChild()).getName()); if (getFirstChild().getBuilder() != ((QueryKeyExpression) getFirstChild()).getBaseExpression()){ return false; DatabaseMapping mapping = descriptor.getMappingForAttributeName(((QueryKeyExpression)getSecondChild()).getName()); if (getSecondChild().getBuilder() != ((QueryKeyExpression) getSecondChild()).getBaseExpression() ){ return false;