use of org.apache.cayenne.map.DbAttribute in project cayenne by apache.
the class Oracle8LOBInsertBatchTranslator method getValuesForLOBUpdateParameters.
@Override
List<Object> getValuesForLOBUpdateParameters(BatchQueryRow row) {
List<DbAttribute> dbAttributes = query.getDbAttributes();
int len = dbAttributes.size();
List<Object> values = new ArrayList<>(len);
for (int i = 0; i < len; i++) {
Object value = row.getValue(i);
DbAttribute attribute = dbAttributes.get(i);
if (isUpdateableColumn(value, attribute.getType())) {
values.add(value);
}
}
return values;
}
use of org.apache.cayenne.map.DbAttribute in project cayenne by apache.
the class Oracle8LOBUpdateBatchTranslator method getValuesForLOBUpdateParameters.
@Override
List<Object> getValuesForLOBUpdateParameters(BatchQueryRow row) {
int len = query.getDbAttributes().size();
UpdateBatchQuery updateBatch = (UpdateBatchQuery) query;
List<Object> values = new ArrayList<>(len);
List<DbAttribute> qualifierAttributes = updateBatch.getQualifierAttributes();
List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes();
int updatedLen = updatedDbAttributes.size();
int qualifierLen = qualifierAttributes.size();
for (int i = 0; i < updatedLen; i++) {
DbAttribute attribute = updatedDbAttributes.get(i);
Object value = row.getValue(i);
if (isUpdateableColumn(value, attribute.getType())) {
values.add(value);
}
}
for (int i = 0; i < qualifierLen; i++) {
values.add(row.getValue(updatedLen + i));
}
return values;
}
use of org.apache.cayenne.map.DbAttribute in project cayenne by apache.
the class OracleAdapter method updatesLOBColumns.
/**
* Utility method that returns <code>true</code> if the query will update at
* least one BLOB or CLOB DbAttribute.
*
* @since 1.2
*/
static boolean updatesLOBColumns(BatchQuery query) {
boolean isInsert = query instanceof InsertBatchQuery;
boolean isUpdate = query instanceof UpdateBatchQuery;
if (!isInsert && !isUpdate) {
return false;
}
List<DbAttribute> updatedAttributes = (isInsert) ? query.getDbAttributes() : ((UpdateBatchQuery) query).getUpdatedAttributes();
for (DbAttribute attr : updatedAttributes) {
int type = attr.getType();
if (type == Types.CLOB || type == Types.BLOB) {
return true;
}
}
return false;
}
use of org.apache.cayenne.map.DbAttribute in project cayenne by apache.
the class PostgresBatchAction method prepareStatement.
@Override
protected PreparedStatement prepareStatement(Connection connection, String queryStr, DbAdapter adapter, boolean generatedKeys) throws SQLException {
if (generatedKeys) {
Collection<DbAttribute> generatedAttributes = query.getDbEntity().getGeneratedAttributes();
String[] generatedPKColumns = new String[generatedAttributes.size()];
int i = 0;
for (DbAttribute generatedAttribute : generatedAttributes) {
if (generatedAttribute.isPrimaryKey()) {
generatedPKColumns[i++] = generatedAttribute.getName().toLowerCase();
}
}
return connection.prepareStatement(queryStr, Arrays.copyOf(generatedPKColumns, i));
}
return connection.prepareStatement(queryStr);
}
use of org.apache.cayenne.map.DbAttribute in project cayenne by apache.
the class DbAttributePathComboBoxEditor method createTreeModelForComboBox.
@Override
protected EntityTreeModel createTreeModelForComboBox(int attributeIndexInTable) {
ObjAttribute attribute = model.getAttribute(attributeIndexInTable).getValue();
Entity firstEntity = null;
if (attribute.getDbAttribute() == null) {
if (attribute.getParent() instanceof ObjEntity) {
DbEntity dbEnt = ((ObjEntity) attribute.getParent()).getDbEntity();
if (dbEnt != null) {
Collection<DbAttribute> attributes = dbEnt.getAttributes();
Collection<DbRelationship> rel = dbEnt.getRelationships();
if (!attributes.isEmpty()) {
Iterator<DbAttribute> iterator = attributes.iterator();
firstEntity = iterator.next().getEntity();
} else if (!rel.isEmpty()) {
Iterator<DbRelationship> iterator = rel.iterator();
firstEntity = iterator.next().getSourceEntity();
}
}
}
} else {
firstEntity = getFirstEntity(attribute);
}
if (firstEntity != null) {
EntityTreeModel treeModel = new EntityTreeModel(firstEntity);
treeModel.setFilter(new EntityTreeAttributeRelationshipFilter());
return treeModel;
}
return null;
}
Aggregations