/** * INTERNAL * (): * Answer true if the SELECTed node has a left and right, and the right represents * a direct-to-field mapping. */ public boolean endsWithDirectToField(GenerationContext context) { DatabaseMapping mapping = resolveMapping(context); return (mapping != null) && mapping.isDirectToFieldMapping(); }
/** Returns true if the specified type denotes a simple state attribute. */ public boolean isSimpleStateAttribute(Object ownerClass, String attribute) { DatabaseMapping mapping = resolveAttributeMapping(ownerClass, attribute); return (mapping != null) && mapping.isDirectToFieldMapping(); }
/** * INTERNAL: * This will return the attribute names for all the direct to field mappings * on this descriptor metadata. This method will typically be called when an * @Embedded or @EmbeddedId attribute has been specified in an @OrderBy. */ public List<String> getOrderByAttributeNames() { if (m_orderByAttributeNames.isEmpty()) { for (DatabaseMapping mapping : getMappings()) { if (mapping.isDirectToFieldMapping()) { m_orderByAttributeNames.add(mapping.getAttributeName()); } } } return m_orderByAttributeNames; }
/** * INTERNAL * Returns the attribute type if the right represents a direct-to-field mapping. */ public Class getTypeOfDirectToField(GenerationContext context) { DatabaseMapping mapping = resolveMapping(context); if ((mapping != null) && mapping.isDirectToFieldMapping()) { return ((DirectToFieldMapping)mapping).getAttributeClassification(); } return null; }
/** * INTERNAL: * Transform the object-level value into a database-level value */ public Object getFieldValue(Object objectValue) { DatabaseMapping mapping = getMapping(); Object fieldValue = objectValue; if ((mapping != null) && (mapping.isDirectToFieldMapping())) { // CR#3623207, check for IN Vector here not in mapping. if (objectValue instanceof Vector) { // This can actually be a vector for IN within expressions... however it would be better for expressions to handle this. Vector values = (Vector)objectValue; Vector fieldValues = new Vector(values.size()); for (int index = 0; index < values.size(); index++) { fieldValues.addElement(getFieldValue(values.get(index))); } fieldValue = fieldValues; } else { fieldValue = ((AbstractDirectMapping)mapping).getFieldValue(objectValue, getSession()); } } return fieldValue; }
if (!mapping.isDirectToFieldMapping()) { mapping.buildShallowOriginalFromRow(databaseRow, original, query, executionSession); if (mapping.isDirectToFieldMapping()) { mapping.buildShallowOriginalFromRow(databaseRow, original, query, executionSession);
/** * resolveClass: Answer the class for the mapping associated with the my variableName in the ownerClass. * Answer null if the node represents a mapping that doesn't exist */ public Class resolveClass(GenerationContext context, Class ownerClass) { DatabaseMapping mapping; mapping = resolveMapping(context, ownerClass); // if we are working with a direct-to-field, or the mapping's null, // return the owner class // Returning the ownerClass when the mapping is null delegates error handling // to the query rather than me if ((mapping == null) || (mapping.isDirectToFieldMapping())) { return ownerClass; } ClassDescriptor descriptor = mapping.getReferenceDescriptor(); return (descriptor==null) ? null : descriptor.getJavaClass(); //return mapping.getReferenceDescriptor().getJavaClass(); }
/** * INTERNAL: * Set the field classification through searching the fields hashtable. */ public void initializeFieldClassification(Session session) throws DescriptorException { if (getFieldToAttributeValues().isEmpty()) { return; } Class type = null; Iterator fieldValuesEnum = getFieldToAttributeValues().keySet().iterator(); while (fieldValuesEnum.hasNext() && (type == null)) { Object value = fieldValuesEnum.next(); if (value != Helper.getNullWrapper()) { type = value.getClass(); } } setFieldClassification(type); // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(type); } } }
/** * INTERNAL: * Set the mapping. */ public void initialize(DatabaseMapping mapping, Session session) { this.mapping = mapping; // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(ClassConstants.APBYTE); } } }
/** * INTERNAL: * Set the mapping. */ public void initialize(DatabaseMapping mapping, Session session) { this.mapping = mapping; // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(ClassConstants.STRING); } } }
/** * INTERNAL: * Assign values from objectRow to the object through the mapping. */ protected void assignReturnValueToMapping(Object object, ReadObjectQuery query, AbstractRecord row, DatabaseField field, DatabaseMapping mapping, Collection handledMappings) { if (handledMappings.contains(mapping)) { return; } Object attributeValue; if (mapping.isAggregateObjectMapping()) { attributeValue = ((AggregateObjectMapping)mapping).readFromReturnRowIntoObject(row, object, query, handledMappings); } else if (mapping.isDirectToFieldMapping()) { attributeValue = mapping.readFromRowIntoObject(row, null, object, query); } else { query.getSession().log(SessionLog.FINEST, SessionLog.QUERY, "field_for_unsupported_mapping_returned", field, getDescriptor()); } }
/** * INTERNAL: return a database field based on a query key name */ public DatabaseField getTargetFieldForQueryKeyName(String queryKeyName) { DatabaseMapping mapping = (DatabaseMapping)getMappingForAttributeName(queryKeyName); if ((mapping != null) && mapping.isDirectToFieldMapping()) { return ((AbstractDirectMapping)mapping).getField(); } //mapping is either null or not direct to field. //check query keys QueryKey queryKey = getDescriptor().getQueryKeyNamed(queryKeyName); if ((queryKey != null) && queryKey.isDirectQueryKey()) { return ((DirectQueryKey)queryKey).getField(); } //nothing found return null; }
if ((mapping == null) || (!mapping.isDirectToFieldMapping())) { hasSimplePrimaryKey = false; break;
/** * INTERNAL: */ public boolean isAttribute() { if (getSession() == null) {// We can't tell, so say no return false; } try { QueryKey queryKey = getQueryKeyOrNull(); if (queryKey != null) { return queryKey.isDirectQueryKey(); } DatabaseMapping mapping = getMapping(); if (mapping != null) { if (mapping.isVariableOneToOneMapping()) { throw QueryException.cannotQueryAcrossAVariableOneToOneMapping(mapping, mapping.getDescriptor()); } else { return mapping.isDirectToFieldMapping(); } } } catch (QueryException e) { throw e;//re-throw the query exception arisen from the query on varibale 1:1 mapping } return false; }
/** * INTERNAL: * Set the mapping. */ public void initialize(DatabaseMapping mapping, Session session) { this.mapping = mapping; // CR#... Mapping must also have the field classification. if (getMapping().isDirectToFieldMapping()) { AbstractDirectMapping directMapping = (AbstractDirectMapping)getMapping(); // Allow user to specify field type to override computed value. (i.e. blob, nchar) if (directMapping.getFieldClassification() == null) { directMapping.setFieldClassification(getDataClass()); } // Set the object class from the attribute, if null. if (getObjectClass() == null) { setObjectClass(directMapping.getAttributeClassification()); } } }
if (mapping.isDirectToFieldMapping()) { Object nullValue = ((AbstractDirectMapping)mapping).getAttributeValue(null, policy.getSession()); mapping.setAttributeValueInObject(copy, nullValue);
/** * INTERNAL: * Used to update a changeRecord that is stored in the CHangeSet with a new value. */ public void updateChangeRecordForAttribute(DatabaseMapping mapping, Object value) { String attributeName = mapping.getAttributeName(); ChangeRecord changeRecord = (ChangeRecord)getChangesForAttributeNamed(attributeName); // bug 2641228 always ensure that we convert the value to the correct type value = ConversionManager.getDefaultManager().convertObject(value, mapping.getAttributeClassification()); if (changeRecord != null) { changeRecord.updateChangeRecordWithNewValue(value); } else if (mapping.isDirectToFieldMapping()) { //if it is direct to field then this is most likely the result of a forced update and // we will need to merge this object changeRecord = new DirectToFieldChangeRecord(this); changeRecord.setAttribute(attributeName); changeRecord.setMapping(mapping); ((DirectToFieldChangeRecord)changeRecord).setNewValue(value); this.addChange(changeRecord); } }
if (mapping.isDirectToFieldMapping()) { fieldValue = ((AbstractDirectMapping)mapping).getFieldValue(pkElementArray[index].getValue(key), (oracle.toplink.essentials.internal.sessions.AbstractSession)session); } else {
} else if (mapping.isDirectToFieldMapping()) { Object attributeValue = mapping.getAttributeValueFromObject(object); objectChangeSet.updateChangeRecordForAttribute(mapping, attributeValue);
if (mapping != null && !mapping.isDirectToFieldMapping()){ return false; if (mapping != null && !mapping.isDirectToFieldMapping()){ return false;