/** * INTERNAL: * Checks to see if it has a query key or mapping with the specified name or not. */ public boolean hasQueryKeyOrMapping(String attributeName) { return (getQueryKeys().containsKey(attributeName) || (getObjectBuilder().getMappingForAttributeName(attributeName) != null)); }
/** * Return the field used for the query key name. */ public DatabaseField getFieldForQueryKeyName(String name) { QueryKey key = getDescriptor().getQueryKeyNamed(name); if (key == null) { DatabaseMapping mapping = getMappingForAttributeName(name); if (mapping == null) { return null; } if (mapping.getFields().isEmpty()) { return null; } return (DatabaseField)mapping.getFields().firstElement(); } if (key.isDirectQueryKey()) { return ((DirectQueryKey)key).getField(); } return null; }
public DatabaseMapping getMapping() { if (getBaseExpression() == null) { return null; } ClassDescriptor aDescriptor = ((DataExpression)getBaseExpression()).getDescriptor(); if (aDescriptor == null) { return null; } return aDescriptor.getObjectBuilder().getMappingForAttributeName(getName()); }
/** * 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; }
/** * INTERNAL: * Merge changes between the objects, this merge algorthim is dependent on the merge manager. */ public void mergeChangesIntoObject(Object target, ObjectChangeSet changeSet, Object source, MergeManager mergeManager) { for (Enumeration changes = changeSet.getChanges().elements(); changes.hasMoreElements();) { ChangeRecord record = (ChangeRecord)changes.nextElement(); //cr 4236, use ObjectBuilder getMappingForAttributeName not the Descriptor one because the // ObjectBuilder method is much more efficient. DatabaseMapping mapping = getMappingForAttributeName(record.getAttribute()); mapping.mergeChangesIntoObject(target, record, source, mergeManager); } // PERF: Avoid events if no listeners. if (getDescriptor().getEventManager().hasAnyEventListeners()) { oracle.toplink.essentials.descriptors.DescriptorEvent event = new oracle.toplink.essentials.descriptors.DescriptorEvent(target); event.setSession(mergeManager.getSession()); event.setOriginalObject(source); event.setChangeSet(changeSet); event.setEventCode(DescriptorEventManager.PostMergeEvent); getDescriptor().getEventManager().executeEvent(event); } }
DatabaseMapping mapping = null; if(attributeName != null) { mapping = getDescriptor().getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping != null && !mapping.getFields().isEmpty()) { field = (DatabaseField)mapping.getFields().firstElement();
/** * INTERNAL: * Create an instance of the composite primary key class for the key object. */ public Object createPrimaryKeyInstance(Object key, AbstractSession session) { Object keyInstance = getPKClassInstance(); ObjectBuilder builder = getDescriptor().getObjectBuilder(); KeyElementAccessor[] pkElementArray = this.getKeyClassFields(getPKClass()); for (int index = 0; index < pkElementArray.length; index++) { KeyElementAccessor accessor = pkElementArray[index]; DatabaseMapping mapping = builder.getMappingForAttributeName(accessor.getAttributeName()); // With session validation, the mapping shouldn't be null at this // point, don't bother checking. while (mapping.isAggregateObjectMapping()) { mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName()); if (mapping == null) { // must be aggregate mapping = builder.getMappingForField(accessor.getDatabaseField()); } } Object fieldValue = mapping.getRealAttributeValueFromObject(key, (oracle.toplink.essentials.internal.sessions.AbstractSession) session); accessor.setValue(keyInstance, fieldValue); } return keyInstance; }
Vector pkVector = new Vector(pkElementArray.length); for (int index = 0; index < pkElementArray.length; index++) { DatabaseMapping mapping = this.getDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName()); if (mapping == null) { mapping = this.getDescriptor().getObjectBuilder().getMappingForField(pkElementArray[index].getDatabaseField()); mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(pkElementArray[index].getAttributeName()); if (mapping == null) {// must be aggregate mapping = this.getDescriptor().getObjectBuilder().getMappingForField(pkElementArray[index].getDatabaseField());
while (attrIter.hasNext()) { String attrName = (String)attrIter.next(); DatabaseMapping mapping = builder.getMappingForAttributeName(attrName); if (mapping == null) {
Object keyFieldValue = keyElements[index].getValue(key); DatabaseField field = keyElements[index].getDatabaseField(); DatabaseMapping mapping = this.getDescriptor().getObjectBuilder().getMappingForAttributeName(keyElements[index].getAttributeName()); if (mapping == null) {// must be aggregate mapping = this.getDescriptor().getObjectBuilder().getMappingForField(field); mapping.setRealAttributeValueInObject(toWriteInto, aggregate); mapping = mapping.getReferenceDescriptor().getObjectBuilder().getMappingForAttributeName(keyElements[index].getAttributeName()); if (mapping == null) {// must be aggregate mapping = this.getDescriptor().getObjectBuilder().getMappingForField(field);
/** * This is used for a remote unit of work. * If the value holder is sent back to the server uninstantiated and * it needs to be instantiated, then we must find the original * object and get the appropriate attribute from it. */ protected Object getValueFromServerObject() { setSession(getRemoteUnitOfWork()); Vector primaryKey = getSession().keyFromObject(getSourceObject()); Object originalObject = getUnitOfWork().getParent().getIdentityMapAccessor().getFromIdentityMap(primaryKey, getSourceObject().getClass()); if (originalObject == null) { originalObject = getUnitOfWork().getParent().readObject(getSourceObject()); } ClassDescriptor descriptor = getSession().getDescriptor(originalObject); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(getSourceAttributeName()); setMapping(mapping); return getMapping().getRealAttributeValueFromObject(originalObject, getSession()); }
mapping = session.getDescriptor(object.getClass()).getObjectBuilder().getMappingForAttributeName(getName());
DatabaseMapping dm = getMappingForAttributeName(qke.getName());
value = mapping.valueFromObject(value, getField(), session); } else { mapping = descriptor.getObjectBuilder().getMappingForAttributeName(getField().getName()); if (mapping != null) { value = mapping.getRealAttributeValueFromObject(value, session);