/** * Adds a column to the insert statement. The column given must exist in the table, and has to be * a valid identifier for the underlying database. Calling this method is only valid after * addTable has been called. */ public void addColumn(String colname) throws tinySQLException { ColumnValue col = new ColumnValue(colname); String tablename = col.getTable(); if (tablename != null) { if (table.getName().equals(tablename) == false) { throw new tinySQLException( "The specified table [" + tablename + "] is not defined in this statement"); } } String name = col.getColumn(); tsColumn tablecol = table.getColumnDefinition(table.findColumn(name)); columns.add(tablecol); }
/** * Gets the column value map. * * @param entity the entity * @param mapping the mapping * @return the column value map * @throws ClassNotFoundException the class not found exception * @throws SQLException the sQL exception * @throws InstantiationException the instantiation exception * @throws IllegalAccessException the illegal access exception * @throws InvocationTargetException the invocation target exception * @throws NoSuchMethodException the no such method exception */ private Map<String, ColumnValue> getColumnValueMap(Object entity, ObjectMapping mapping) throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Map<String, ColumnValue> valueMap = new HashMap<String, ColumnValue>(); String columnName = null; Object value = null; ColumnValue columnValue = null; Collection<PropertyMapping> c = mapping.getPropertyMap().values(); for (PropertyMapping pm : c) { if (pm.isComplexType()) { continue; } columnName = pm.getColumnName(); if (valueMap.containsKey(columnName)) { continue; } if (!filter(pm)) { continue; } if (entity == null) { value = null; } else { value = PropertyUtils.getProperty(entity, pm.getPropertyName()); } columnValue = new ColumnValue(); columnValue.setColumnName(columnName); columnValue.setColumnvalue(value); columnValue.setPropertyMapping(pm); if (pm.isPrimaryKey()) { columnValue.setPrimaryKey(true); } if (filter(columnValue)) { valueMap.put(columnName, columnValue); } } return valueMap; }
@Override public RowBasedSet addRow(Object[] fields) { TRow tRow = new TRow(); for (int i = 0; i < fields.length; i++) { tRow.addToColVals(ColumnValue.toTColumnValue(descriptors[i], fields[i])); } rows.add(tRow); return this; }
@Override boolean addColumn( String recordKey, CompositeColumnName column, Object value, String className, RowMutator mutator, Integer ttl, DataObject obj) { String rowKey = getRowKey(column, value); ColumnListMutation<IndexColumnName> indexColList = mutator.getIndexColumnList(indexCF, rowKey); IndexColumnName indexEntry = new IndexColumnName(className, recordKey, value.toString(), mutator.getTimeUUID()); ColumnValue.setColumn(indexColList, indexEntry, value.toString(), ttl); return true; }