/** * Sets the value to be inserted in the given table column - the column references the given * {@link InsertField} and thus must have the same value as the referenced column. * * <p>In complex + erroneous mappings (or feature instances), it may happen that different * property values (mapped to the same column) imply different values. This is checked for and in * case an {@link TransactionException} is thrown. * * @param column * @param referencedField * @throws TransactionException if the value for the column clashes */ public void linkColumn(String column, InsertField referencedField) throws TransactionException { if (referencedField.getValue() == null) { LOG.logError("linkColumn (): referencedField is null"); throw new TransactionException("linkColumn (): referenced field is null!"); } InsertField presentField = this.columnMap.get(column); if (presentField != null && (!presentField.getValue().toString().equals(referencedField.getValue().toString()))) { Object[] params = new Object[] { column, this.table, presentField.getValue().toString(), referencedField.getValue().toString() }; String msg = Messages.getMessage("DATASTORE_AMBIGOUS_COLUMN_VALUES", params); throw new TransactionException(msg); } InsertField field = presentField; if (presentField != null) { presentField.relinkField(referencedField); } else { field = new InsertField(this, column, referencedField); this.columnMap.put(column, field); } referencedField.addReferencingField(field); }
/** * Sets the value to be inserted in the given table column. * * <p>In complex + erroneous mappings (or feature instances), it may happen that different * property values (mapped to the same column) imply different values. This is checked for and in * case an {@link TransactionException} is thrown. * * @param column * @param value * @param sqlType * @param isPK * @return column + value to be set * @throws TransactionException if the value for the column clashes */ public InsertField setColumn(String column, Object value, int sqlType, boolean isPK) throws TransactionException { InsertField field = new InsertField(this, column, sqlType, value, isPK); InsertField presentField = columnMap.get(column); if (presentField != null && (!presentField.getValue().toString().equals(value.toString()))) { Object[] params = new Object[] {column, this.table, presentField.getValue().toString(), value.toString()}; String msg = Messages.getMessage("DATASTORE_AMBIGOUS_COLUMN_VALUES", params); throw new TransactionException(msg); } if (presentField == null) { this.columnMap.put(column, field); } // TODO type check return field; }