/** * Build the row representation of an object. */ public AbstractRecord buildRow(Object object, AbstractSession session) { return buildRow(createRecord(), object, session); }
/** * Build the row representation of the object for update. The row built does not * contain entries for uninstantiated attributes. */ public AbstractRecord buildRowForShallowInsertWithChangeSet(ObjectChangeSet objectChangeSet, AbstractSession session) { return buildRowForShallowInsertWithChangeSet(createRecord(), objectChangeSet, session); }
/** * Build the row of all of the fields used for insertion. */ public AbstractRecord buildTemplateInsertRow(AbstractSession session) { AbstractRecord databaseRow = createRecord(); buildTemplateInsertRow(session, databaseRow); return databaseRow; }
/** * Build the row representation of the object for update. The row built does not * contain entries for non-relationship fields. */ public AbstractRecord buildRowForShallowDelete(Object object, AbstractSession session) { return buildRowForShallowDelete(createRecord(), object, session); }
/** * Build the row representation of the object for update. The row built does not * contain entries for uninstantiated attributes. */ public AbstractRecord buildRowForShallowInsert(Object object, AbstractSession session) { return buildRowForShallowInsert(createRecord(), object, session); }
/** * Build the row representation of an object. */ public AbstractRecord buildRowWithChangeSet(ObjectChangeSet objectChangeSet, AbstractSession session) { return buildRowWithChangeSet(createRecord(), objectChangeSet, session); }
/** * Build the row representation of an object. The row built is used only for translations * for the expressions in the expresion framework. */ public AbstractRecord buildRowForTranslation(Object object, AbstractSession session) { AbstractRecord databaseRow = createRecord(); for (Iterator mappings = getPrimaryKeyMappings().iterator(); mappings.hasNext();) { DatabaseMapping mapping = (DatabaseMapping)mappings.next(); if (mapping != null) { mapping.writeFromObjectIntoRow(object, databaseRow, session); } } // If this descriptor has multiple tables then we need to append the primary keys for // the non default tables, this is require for m-m, dc defined in the Builder that prefixes the wrong table name. // Ideally the mappings should take part in building the translation row so they can add required values. addPrimaryKeyForNonDefaultTable(databaseRow, object, session); return databaseRow; }
/** * Build the row representation of the object for update. The row built does not * contain entries for uninstantiated attributes. */ public AbstractRecord buildRowForUpdateWithChangeSet(WriteObjectQuery query) { AbstractRecord databaseRow = createRecord(); for (Iterator changeRecords = query.getObjectChangeSet().getChanges().iterator(); changeRecords.hasNext();) { ChangeRecord changeRecord = (ChangeRecord)changeRecords.next(); DatabaseMapping mapping = changeRecord.getMapping(); mapping.writeFromObjectIntoRowWithChangeRecord(changeRecord, databaseRow, query.getSession()); } return databaseRow; }
/** * INTERNAL: * Extract the reference pk for rvh usage in remote model. */ public AbstractRecord extractPrimaryKeyRowForSourceObject(Object domainObject, AbstractSession session) { AbstractRecord databaseRow = getDescriptor().getObjectBuilder().createRecord(); writeFromObjectIntoRow(domainObject, databaseRow, session); return databaseRow; }
/** * Build the row representation of an object. */ public AbstractRecord buildRowForWhereClause(ObjectLevelModifyQuery query) { AbstractRecord databaseRow = createRecord(); for (Iterator mappings = getDescriptor().getMappings().iterator(); mappings.hasNext();) { DatabaseMapping mapping = (DatabaseMapping)mappings.next(); mapping.writeFromObjectIntoRowForWhereClause(query, databaseRow); } // If this descriptor has multiple tables then we need to append the primary keys for // the non default tables. if (!getDescriptor().isAggregateDescriptor()) { addPrimaryKeyForNonDefaultTable(databaseRow); } return databaseRow; }
/** * Build the row from the primary key values. */ public AbstractRecord buildRowFromPrimaryKeyValues(Vector key, AbstractSession session) { AbstractRecord databaseRow = createRecord(key.size()); int keySize = key.size(); for (int index = 0; index < keySize; index++) { DatabaseField field = (DatabaseField)getDescriptor().getPrimaryKeyFields().get(index); Object value = key.elementAt(index); value = session.getPlatform(getDescriptor().getJavaClass()).getConversionManager().convertObject(value, field.getType()); databaseRow.put(field, value); } return databaseRow; }
/** * Build the row representation of the object for update. The row built does not * contain entries for uninstantiated attributes. */ public AbstractRecord buildTemplateUpdateRow(AbstractSession session) { AbstractRecord databaseRow = createRecord(); for (Iterator mappings = getNonPrimaryKeyMappings().iterator(); mappings.hasNext();) { DatabaseMapping mapping = (DatabaseMapping)mappings.next(); mapping.writeUpdateFieldsIntoRow(databaseRow, session); } if (getDescriptor().usesOptimisticLocking()) { getDescriptor().getOptimisticLockingPolicy().addLockFieldsToUpdateRow(databaseRow, session); } return databaseRow; }
/** * Extract primary key attribute values from the domainObject. */ public AbstractRecord extractPrimaryKeyRowFromObject(Object domainObject, AbstractSession session) { AbstractRecord databaseRow = createRecord(getPrimaryKeyMappings().size()); // PERF: use index not enumeration. for (int index = 0; index < getPrimaryKeyMappings().size(); index++) { ((DatabaseMapping)getPrimaryKeyMappings().get(index)).writeFromObjectIntoRow(domainObject, databaseRow, session); } // PERF: optimize simple primary key case, no need to remap. if (getDescriptor().hasSimplePrimaryKey()) { return databaseRow; } AbstractRecord primaryKeyRow = createRecord(getPrimaryKeyMappings().size()); List primaryKeyFields = getDescriptor().getPrimaryKeyFields(); for (int index = 0; index < primaryKeyFields.size(); index++) { // Ensure that the type extracted from the object is the same type as in the descriptor, // the main reason for this is that 1-1 can optimize on vh by getting from the row as the row-type. Class classification = (Class)getPrimaryKeyClassifications().get(index); DatabaseField field = (DatabaseField)primaryKeyFields.get(index); Object value = databaseRow.get(field); primaryKeyRow.put(field, session.getPlatform(domainObject.getClass()).convertObject(value, classification)); } return primaryKeyRow; }
AbstractRecord databaseRow = createRecord(getPrimaryKeyMappings().size());
/** * Build the row representation of the object for update. The row built does not * contain entries for uninstantiated attributes. */ public AbstractRecord buildRowForUpdate(WriteObjectQuery query) { AbstractRecord databaseRow = createRecord(); for (Iterator mappings = getNonPrimaryKeyMappings().iterator(); mappings.hasNext();) { DatabaseMapping mapping = (DatabaseMapping)mappings.next(); mapping.writeFromObjectIntoRowForUpdate(query, databaseRow); } // If this descriptor is involved in inheritence and is an Aggregate, add the class type. // Added Nov 8, 2000 Mostly by PWK but also JED // Prs 24801 // Modified Dec 11, 2000 TGW with assitance from PWK // Prs 27554 if (getDescriptor().hasInheritance() && getDescriptor().isAggregateDescriptor()) { if (query.getObject() != null) { if (query.getBackupClone() == null) { getDescriptor().getInheritancePolicy().addClassIndicatorFieldToRow(databaseRow); } else { if (!query.getObject().getClass().equals(query.getBackupClone().getClass())) { getDescriptor().getInheritancePolicy().addClassIndicatorFieldToRow(databaseRow); } } } } return databaseRow; }
/** * Return the row with primary keys and their values from the given expression. */ public Vector extractPrimaryKeyFromExpression(boolean requiresExactMatch, Expression expression, AbstractRecord translationRow, AbstractSession session) { AbstractRecord primaryKeyRow = createRecord(getPrimaryKeyMappings().size()); //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression. boolean isValid = expression.extractPrimaryKeyValues(requiresExactMatch, getDescriptor(), primaryKeyRow, translationRow); if (requiresExactMatch && (!isValid)) { return null; } // Check that the sizes match. if (primaryKeyRow.size() != getDescriptor().getPrimaryKeyFields().size()) { return null; } return extractPrimaryKeyFromRow(primaryKeyRow, session); }
/** * Return the row with primary keys and their values from the given expression. */ public AbstractRecord extractPrimaryKeyRowFromExpression(Expression expression, AbstractRecord translationRow, AbstractSession session) { AbstractRecord primaryKeyRow = createRecord(getPrimaryKeyMappings().size()); //put the curent session onthe expression builder for use later store current session incase //it is required at a later stage AbstractSession oldSession = expression.getBuilder().getSession(); expression.getBuilder().setSession(session.getRootSession(null)); // Get all the field & values from expression boolean isValid = expression.extractPrimaryKeyValues(true, getDescriptor(), primaryKeyRow, translationRow); expression.getBuilder().setSession(session.getRootSession(null)); if (!isValid) { return null; } // Check that the sizes match up if (primaryKeyRow.size() != getDescriptor().getPrimaryKeyFields().size()) { return null; } return primaryKeyRow; }
AbstractRecord tempRow = createRecord(1); tempRow.put(sequenceNumberField, sequenceValue);
/** * INTERNAL: * Update the row, object and change set with the version value. * This handles the version being mapped in nested aggregates, writable or read-only. */ protected void updateWriteLockValueForWrite(ObjectLevelModifyQuery query, Object lockValue) { query.getModifyRow().put(getWriteLockField(), lockValue); ObjectChangeSet objectChangeSet = query.getObjectChangeSet(); if (objectChangeSet != null) { objectChangeSet.setWriteLockValue(lockValue); } // CR#3173211 // If the value is stored in the cache or object, there still may // be read-only mappings for it, so the object must always be updated for // any writable or read-only mappings for the version value. // Reuse the method used for returning as has the same requirements. AbstractRecord record = getDescriptor().getObjectBuilder().createRecord(1); record.put(getWriteLockField(), lockValue); getDescriptor().getObjectBuilder().assignReturnRow(query.getObject(), query.getSession(), record); if (query.getSession().isUnitOfWork() && (((UnitOfWorkImpl)query.getSession()).getUnitOfWorkChangeSet() != null)) { if (objectChangeSet == null) { // For aggregate collections the change set may be null, as they use the old commit still. objectChangeSet = (ObjectChangeSet)((UnitOfWorkImpl)query.getSession()).getUnitOfWorkChangeSet().getObjectChangeSetForClone(query.getObject()); } query.getQueryMechanism().updateChangeSet(getDescriptor(), objectChangeSet, record, query.getObject()); } }
AbstractRecord tempRow = getDescriptor().getObjectBuilder().createRecord();