/** * INTERNAL: * The translation row may require additional fields than the primary key if the mapping in not on the primary key. */ protected void prepareTranslationRow(AbstractRecord translationRow, Object object, AbstractSession session) { // Make sure that each source key field is in the translation row. for (Enumeration sourceFieldsEnum = getSourceKeyFields().elements(); sourceFieldsEnum.hasMoreElements();) { DatabaseField sourceKey = (DatabaseField)sourceFieldsEnum.nextElement(); if (!translationRow.containsKey(sourceKey)) { Object value = getDescriptor().getObjectBuilder().extractValueFromObjectForField(object, sourceKey, session); translationRow.put(sourceKey, value); } } }
/** * INTERNAL: * Extract the primary key value from the source row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractPrimaryKeyFromRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceKeyFields().size()); for (Enumeration fieldEnum = getSourceKeyFields().elements(); fieldEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)fieldEnum.nextElement(); Object value = row.get(field); // Must ensure the classification gets a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(field)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
/** * INTERNAL: * Extract the source primary key value from the relation row. * Used for batch reading, most following same order and fields as in the mapping. */ protected Vector extractKeyFromTargetRow(AbstractRecord row, AbstractSession session) { Vector key = new Vector(getSourceRelationKeyFields().size()); for (int index = 0; index < getSourceRelationKeyFields().size(); index++) { DatabaseField relationField = getSourceRelationKeyFields().elementAt(index); DatabaseField sourceField = getSourceKeyFields().elementAt(index); Object value = row.get(relationField); // Must ensure the classification gets a cache hit. try { value = session.getDatasourcePlatform().getConversionManager().convertObject(value, getDescriptor().getObjectBuilder().getFieldClassification(sourceField)); } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(this, getDescriptor(), e); } key.addElement(value); } return key; }
final RelationalDescriptor descriptor = (RelationalDescriptor) databaseMapping.getDescriptor();
/** * INTERNAL: * Verifies listOrderField's table: it must be relation table. * Precondition: listOrderField != null. */ @Override protected void buildListOrderField() { if(this.listOrderField.hasTableName()) { if(!getRelationTable().equals(this.listOrderField.getTable())) { throw DescriptorException.listOrderFieldTableIsWrong(this.getDescriptor(), this, this.listOrderField.getTable(), getRelationTable()); } } else { listOrderField.setTable(getRelationTable()); } this.listOrderField = getDescriptor().buildField(this.listOrderField, getRelationTable()); }
/** * INTERNAL: * Verifies listOrderField's table: it must be relation table. * Precondition: listOrderField != null. */ @Override protected void buildListOrderField() { if(this.listOrderField.hasTableName()) { if(!getRelationTable().equals(this.listOrderField.getTable())) { throw DescriptorException.listOrderFieldTableIsWrong(this.getDescriptor(), this, this.listOrderField.getTable(), getRelationTable()); } } else { listOrderField.setTable(getRelationTable()); } this.listOrderField = getDescriptor().buildField(this.listOrderField, getRelationTable()); }
/** * INTERNAL: * Verifies listOrderField's table: it must be relation table. * Precondition: listOrderField != null. */ protected void buildListOrderField() { if(this.listOrderField.hasTableName()) { if(!getRelationTable().equals(this.listOrderField.getTable())) { throw DescriptorException.listOrderFieldTableIsWrong(this.getDescriptor(), this, this.listOrderField.getTable(), getRelationTable()); } } else { listOrderField.setTable(getRelationTable()); } this.listOrderField = getDescriptor().buildField(this.listOrderField, getRelationTable()); }
getDescriptor().getPreDeleteMappings().add(this);
getDescriptor().addPreDeleteMapping(this);
getDescriptor().addPreDeleteMapping(this);