use of org.apache.cayenne.access.sqlbuilder.UpdateBuilder in project cayenne by apache.
the class SoftDeleteBatchTranslator method getSql.
@Override
public String getSql() {
DeleteBatchQuery query = context.getQuery();
DbAttribute deleteAttribute = query.getDbEntity().getAttribute(deletedFieldName);
UpdateBuilder updateBuilder = update(context.getRootDbEntity()).set(column(deletedFieldName).attribute(deleteAttribute).eq(SQLBuilder.value(true).attribute(deleteAttribute))).where(buildQualifier(query.getDbAttributes()));
String sql = doTranslate(updateBuilder);
String typeName = TypesMapping.getJavaBySqlType(deleteAttribute.getType());
ExtendedType<?> extendedType = context.getAdapter().getExtendedTypes().getRegisteredType(typeName);
bindings[0].include(1, true, extendedType);
return sql;
}
use of org.apache.cayenne.access.sqlbuilder.UpdateBuilder in project cayenne by apache.
the class UpdateBatchTranslator method getSql.
@Override
public String getSql() {
UpdateBatchQuery query = context.getQuery();
UpdateBuilder updateBuilder = SQLBuilder.update(context.getRootDbEntity());
for (DbAttribute attr : query.getUpdatedAttributes()) {
updateBuilder.set(SQLBuilder.column(attr.getName()).attribute(attr).eq(SQLBuilder.value(1).attribute(attr)));
}
updateBuilder.where(buildQualifier(query.getQualifierAttributes()));
return doTranslate(updateBuilder);
}
Aggregations