use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class FirebirdMergerTokenFactory method createSetNotNullToDb.
@Override
public MergerToken createSetNotNullToDb(DbEntity entity, DbAttribute column) {
return new SetNotNullToDb(entity, column) {
public List<String> createSql(DbAdapter adapter) {
QuotingStrategy context = adapter.getQuotingStrategy();
String entityName = context.quotedFullyQualifiedName(getEntity());
String columnName = context.quotedName(getColumn());
// but this might be achived by modyfication of system tables
return Collections.singletonList(String.format("UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = 1 " + "WHERE RDB$FIELD_NAME = '%s' AND RDB$RELATION_NAME = '%s'", columnName, entityName));
}
};
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class MySQLMergerTokenFactory method createSetNotNullToDb.
@Override
public MergerToken createSetNotNullToDb(final DbEntity entity, final DbAttribute column) {
return new SetNotNullToDb(entity, column) {
@Override
public List<String> createSql(DbAdapter adapter) {
StringBuffer sqlBuffer = new StringBuffer();
QuotingStrategy context = adapter.getQuotingStrategy();
sqlBuffer.append("ALTER TABLE ");
sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
sqlBuffer.append(" CHANGE ");
sqlBuffer.append(context.quotedName(getColumn()));
sqlBuffer.append(" ");
adapter.createTableAppendColumn(sqlBuffer, column);
return Collections.singletonList(sqlBuffer.toString());
}
};
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class SybaseMergerTokenFactory method createStringQuery.
private static StringBuffer createStringQuery(DbAdapter adapter, DbEntity entity, DbAttribute column) {
StringBuffer sqlBuffer = new StringBuffer();
QuotingStrategy context = adapter.getQuotingStrategy();
sqlBuffer.append("ALTER TABLE ");
sqlBuffer.append(context.quotedFullyQualifiedName(entity));
sqlBuffer.append(" MODIFY ");
adapter.createTableAppendColumn(sqlBuffer, column);
return sqlBuffer;
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class SetGeneratedFlagToDb method createSql.
@SuppressWarnings("unchecked")
@Override
public List<String> createSql(DbAdapter adapter) {
if (!adapter.supportsGeneratedKeys()) {
return (List<String>) Collections.EMPTY_LIST;
}
QuotingStrategy context = adapter.getQuotingStrategy();
StringBuffer builder = new StringBuffer();
builder.append("ALTER TABLE ").append(context.quotedFullyQualifiedName(getEntity()));
appendAlterColumnClause(adapter, builder);
if (isGenerated) {
appendAutoIncrement(adapter, builder);
} else {
appendDropAutoIncrement(adapter, builder);
}
return Collections.singletonList(builder.toString());
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class SetGeneratedFlagToDb method appendAlterColumnClause.
protected void appendAlterColumnClause(DbAdapter adapter, StringBuffer builder) {
QuotingStrategy context = adapter.getQuotingStrategy();
builder.append(" ALTER COLUMN ").append(context.quotedName(getColumn())).append(" ");
}
Aggregations