/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * If mapping overrides this method it must override writeFromObjectIntoRowForUpdateAfterShallowInsert method, too. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { writeFromObjectIntoRow(object, row, session, WriteType.INSERT); }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { writeFromObjectIntoRow(object, row, session); }
/** * INTERNAL: * This row is built for shallow insert which happens in case of bidirectional inserts. * If mapping overrides this method it must override writeFromObjectIntoRowForUpdateAfterShallowInsert method, too. */ public void writeFromObjectIntoRowForShallowInsert(Object object, AbstractRecord row, AbstractSession session) { writeFromObjectIntoRow(object, row, session, WriteType.INSERT); }
public void writeOutMappings(XMLRecord row, Object object, AbstractSession session) { List<DatabaseMapping> mappings = getDescriptor().getMappings(); for (int index = 0; index < mappings.size(); index++) { DatabaseMapping mapping = mappings.get(index); mapping.writeFromObjectIntoRow(object, row, session, WriteType.UNDEFINED); } } public void addNamespaceDeclarations(Document document) {
public void writeOutMappings(XMLRecord row, Object object, AbstractSession session) { Vector mappings = getDescriptor().getMappings(); for (int index = 0; index < mappings.size(); index++) { DatabaseMapping mapping = (DatabaseMapping)mappings.get(index); mapping.writeFromObjectIntoRow(object, row, session); } } public void addNamespaceDeclarations(Document document) {
public void writeOutMappings(XMLRecord row, Object object, AbstractSession session) { List<DatabaseMapping> mappings = getDescriptor().getMappings(); for (int index = 0; index < mappings.size(); index++) { DatabaseMapping mapping = mappings.get(index); mapping.writeFromObjectIntoRow(object, row, session, WriteType.UNDEFINED); } } public void addNamespaceDeclarations(Document document) {
/** * INTERNAL: * Write the attribute value from the object to the row for update. */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord row) { writeFromObjectIntoRow(query.getObject(), row, query.getSession()); }
/** * INTERNAL: */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord row) { writeFromObjectIntoRow(query.getObject(), row, query.getSession(), WriteType.UPDATE); }
/** * INTERNAL: */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord row) { writeFromObjectIntoRow(query.getObject(), row, query.getSession(), WriteType.UPDATE); }
/** * Build the row representation of an object. The row built is used only for translations * for the expressions in the expression framework. */ public AbstractRecord buildRowForTranslation(Object object, AbstractSession session) { AbstractRecord databaseRow = createRecord(session); List<DatabaseMapping> primaryKeyMappings = getPrimaryKeyMappings(); int size = primaryKeyMappings.size(); for (int index = 0; index < size; index++) { DatabaseMapping mapping = primaryKeyMappings.get(index); if (mapping != null) { mapping.writeFromObjectIntoRow(object, databaseRow, session, WriteType.UNDEFINED); } } // 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. if (this.descriptor.hasMultipleTables()) { addPrimaryKeyForNonDefaultTable(databaseRow, object, session); } return databaseRow; }
/** * Build the row representation of an object. The row built is used only for translations * for the expressions in the expression framework. */ public AbstractRecord buildRowForTranslation(Object object, AbstractSession session) { AbstractRecord databaseRow = createRecord(session); List<DatabaseMapping> primaryKeyMappings = getPrimaryKeyMappings(); int size = primaryKeyMappings.size(); for (int index = 0; index < size; index++) { DatabaseMapping mapping = primaryKeyMappings.get(index); if (mapping != null) { mapping.writeFromObjectIntoRow(object, databaseRow, session, WriteType.UNDEFINED); } } // 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. if (this.descriptor.hasMultipleTables()) { addPrimaryKeyForNonDefaultTable(databaseRow, object, session); } return databaseRow; }
/** * INTERNAL: * A subclass should implement this method if it wants different behavior. * Write the attribute value from the object to the row. */ public void writeFromObjectIntoRowForWhereClause(ObjectLevelModifyQuery query, AbstractRecord row) { Object object; if (query.isDeleteObjectQuery()) { object = query.getObject(); } else { object = query.getBackupClone(); } writeFromObjectIntoRow(object, row, query.getSession()); }
/** * INTERNAL: * A subclass should implement this method if it wants different behavior. * Write the attribute value from the object to the row. */ public void writeFromObjectIntoRowForWhereClause(ObjectLevelModifyQuery query, AbstractRecord row) { Object object; if (query.isDeleteObjectQuery()) { object = query.getObject(); } else { object = query.getBackupClone(); } writeFromObjectIntoRow(object, row, query.getSession(), WriteType.UNDEFINED); }
/** * INTERNAL: * A subclass should implement this method if it wants different behavior. * Write the attribute value from the object to the row. */ public void writeFromObjectIntoRowForWhereClause(ObjectLevelModifyQuery query, AbstractRecord row) { Object object; if (query.isDeleteObjectQuery()) { object = query.getObject(); } else { object = query.getBackupClone(); } writeFromObjectIntoRow(object, row, query.getSession(), WriteType.UNDEFINED); }
/** * Extract primary key attribute values from the domainObject. */ public AbstractRecord extractPrimaryKeyRowFromObject(Object domainObject, AbstractSession session) { AbstractRecord databaseRow = createRecord(getPrimaryKeyMappings().size(), session); // PERF: use index not enumeration. for (int index = 0; index < getPrimaryKeyMappings().size(); index++) { getPrimaryKeyMappings().get(index).writeFromObjectIntoRow(domainObject, databaseRow, session, WriteType.UNDEFINED); } // PERF: optimize simple primary key case, no need to remap. if (this.descriptor.hasSimplePrimaryKey()) { return databaseRow; } AbstractRecord primaryKeyRow = createRecord(getPrimaryKeyMappings().size(), session); List primaryKeyFields = this.descriptor.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 = 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; }
/** * INTERNAL: * Values to be included in the locking mechanism are added to the translation row. * For changed fields the normal build row is ok as only changed fields matter. */ public void addLockValuesToTranslationRow(ObjectLevelModifyQuery query) { verifyUsage(query.getSession()); Object object; if (query.isDeleteObjectQuery()) { return; } object = query.getBackupClone(); for (Enumeration enumtr = query.getModifyRow().keys(); enumtr.hasMoreElements();) { DatabaseField field = (DatabaseField)enumtr.nextElement(); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForField(field); mapping.writeFromObjectIntoRow(object, query.getTranslationRow(), query.getSession()); } }
/** * Build the row representation of an object. */ public AbstractRecord buildRow(AbstractRecord databaseRow, Object object, AbstractSession session, WriteType writeType) { // PERF: Avoid synchronized enumerator as is concurrency bottleneck. List mappings = this.descriptor.getMappings(); int mappingsSize = mappings.size(); for (int index = 0; index < mappingsSize; index++) { DatabaseMapping mapping = (DatabaseMapping)mappings.get(index); mapping.writeFromObjectIntoRow(object, databaseRow, session, writeType); } // If this descriptor is involved in inheritance add the class type. if (this.descriptor.hasInheritance()) { this.descriptor.getInheritancePolicy().addClassIndicatorFieldToRow(databaseRow); } // If this descriptor has multiple tables then we need to append the primary keys for // the non default tables. if (this.descriptor.hasMultipleTables() && !this.descriptor.isAggregateDescriptor()) { addPrimaryKeyForNonDefaultTable(databaseRow, object, session); } // If the session uses multi-tenancy, add the tenant id field. if (getDescriptor().hasMultitenantPolicy()) { getDescriptor().getMultitenantPolicy().addFieldsToRow(databaseRow, session); } return databaseRow; } /**
/** * 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.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession(), WriteType.UNDEFINED); } }
/** * 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.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession(), WriteType.UNDEFINED); } }
/** * 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.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession()); } }