use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.
the class SQLTemplateAction method bindExtendedTypes.
private void bindExtendedTypes(ParameterBinding[] bindings) {
int i = 1;
for (ParameterBinding binding : bindings) {
Object value = binding.getValue();
ExtendedType extendedType = value != null ? getAdapter().getExtendedTypes().getRegisteredType(value.getClass()) : getAdapter().getExtendedTypes().getDefaultType();
binding.setExtendedType(extendedType);
binding.setStatementPosition(i++);
}
}
use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.
the class DeleteBatchTranslator method doUpdateBindings.
@Override
protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
int len = bindings.length;
DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query;
for (int i = 0, j = 1; i < len; i++) {
DbAttributeBinding b = bindings[i];
// skip null attributes... they are translated as "IS NULL"
if (deleteBatch.isNull(b.getAttribute())) {
b.exclude();
} else {
Object value = row.getValue(i);
ExtendedType extendedType = value != null ? adapter.getExtendedTypes().getRegisteredType(value.getClass()) : adapter.getExtendedTypes().getDefaultType();
b.include(j++, value, extendedType);
}
}
return bindings;
}
use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.
the class InsertBatchTranslator method doUpdateBindings.
@Override
protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
int len = bindings.length;
for (int i = 0, j = 1; i < len; i++) {
DbAttributeBinding b = bindings[i];
// exclusions are permanent
if (!b.isExcluded()) {
Object value = row.getValue(i);
ExtendedType extendedType = value != null ? adapter.getExtendedTypes().getRegisteredType(value.getClass()) : adapter.getExtendedTypes().getDefaultType();
b.include(j++, value, extendedType);
}
}
return bindings;
}
use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.
the class SoftDeleteBatchTranslator method doUpdateBindings.
@Override
protected DbAttributeBinding[] doUpdateBindings(BatchQueryRow row) {
int len = bindings.length;
DeleteBatchQuery deleteBatch = (DeleteBatchQuery) query;
// skip position 0... Otherwise follow super algorithm
for (int i = 1, j = 2; i < len; i++) {
DbAttributeBinding b = bindings[i];
// skip null attributes... they are translated as "IS NULL"
if (deleteBatch.isNull(b.getAttribute())) {
b.exclude();
} else {
Object value = row.getValue(i - 1);
ExtendedType extendedType = value != null ? adapter.getExtendedTypes().getRegisteredType(value.getClass()) : adapter.getExtendedTypes().getDefaultType();
b.include(j++, value, extendedType);
}
}
return bindings;
}
use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.
the class SoftDeleteBatchTranslator method createBindings.
@Override
protected DbAttributeBinding[] createBindings() {
DbAttributeBinding[] superBindings = super.createBindings();
int slen = superBindings.length;
DbAttributeBinding[] bindings = new DbAttributeBinding[slen + 1];
DbAttribute deleteAttribute = query.getDbEntity().getAttribute(deletedFieldName);
String typeName = TypesMapping.getJavaBySqlType(deleteAttribute.getType());
ExtendedType extendedType = adapter.getExtendedTypes().getRegisteredType(typeName);
bindings[0] = new DbAttributeBinding(deleteAttribute);
bindings[0].include(1, true, extendedType);
System.arraycopy(superBindings, 0, bindings, 1, slen);
return bindings;
}
Aggregations