use of com.revolsys.jdbc.field.JdbcFieldDefinition in project com.revolsys.open by revolsys.
the class AbstractJdbcRecordStore method addRowIdFieldDefinition.
/**
* Add a new field definition for record definitions that don't have a primary key.
*
* @param recordDefinition
*/
protected void addRowIdFieldDefinition(final RecordDefinitionImpl recordDefinition) {
final Object tableType = recordDefinition.getProperty("tableType");
if ("TABLE".equals(tableType)) {
final JdbcFieldDefinition idFieldDefinition = newRowIdFieldDefinition();
if (idFieldDefinition != null) {
recordDefinition.addField(idFieldDefinition);
final String idFieldName = idFieldDefinition.getName();
recordDefinition.setIdFieldName(idFieldName);
}
}
}
use of com.revolsys.jdbc.field.JdbcFieldDefinition in project com.revolsys.open by revolsys.
the class SqlCondition method appendParameters.
@Override
public int appendParameters(int index, final PreparedStatement statement) {
for (int i = 0; i < this.parameterValues.size(); i++) {
final Object value = this.parameterValues.get(i);
JdbcFieldDefinition jdbcAttribute = null;
if (i < this.parameterAttributes.size()) {
final FieldDefinition attribute = this.parameterAttributes.get(i);
if (attribute instanceof JdbcFieldDefinition) {
jdbcAttribute = (JdbcFieldDefinition) attribute;
}
}
if (jdbcAttribute == null) {
jdbcAttribute = JdbcFieldDefinition.newFieldDefinition(value);
}
try {
index = jdbcAttribute.setPreparedStatementValue(statement, index, value);
} catch (final SQLException e) {
throw new RuntimeException("Unable to set value: " + value, e);
}
}
return index;
}
use of com.revolsys.jdbc.field.JdbcFieldDefinition in project com.revolsys.open by revolsys.
the class PostgreSQLRecordStore method addField.
@Override
protected JdbcFieldDefinition addField(final JdbcRecordDefinition recordDefinition, final String dbColumnName, final String name, final String dbDataType, final int sqlType, final int length, final int scale, final boolean required, final String description) {
final JdbcFieldDefinition field;
if (dbDataType.charAt(0) == '_') {
final String elementDbDataType = dbDataType.substring(1);
final JdbcFieldAdder fieldAdder = getFieldAdder(elementDbDataType);
final JdbcFieldDefinition elementField = fieldAdder.newField(this, recordDefinition, dbColumnName, name, elementDbDataType, sqlType, length, scale, required, description);
final DataType elementDataType = elementField.getDataType();
final CollectionDataType listDataType = new CollectionDataType("List" + elementDataType.getName(), List.class, elementDataType);
field = new PostgreSQLArrayFieldDefinition(dbColumnName, name, listDataType, sqlType, length, scale, required, description, elementField, getProperties());
recordDefinition.addField(field);
} else {
field = super.addField(recordDefinition, dbColumnName, name, dbDataType, sqlType, length, scale, required, description);
}
if (!dbColumnName.matches("[a-z_]+")) {
field.setQuoteName(true);
}
return field;
}
Aggregations