Search in sources :

Example 1 with ASTNotEqual

use of org.apache.cayenne.exp.parser.ASTNotEqual in project cayenne by apache.

the class DB2QualifierTranslator method processColumnWithQuoteSqlIdentifiers.

@Override
protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) {
    SimpleNode parent = null;
    if (pathExp instanceof SimpleNode) {
        parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent();
    }
    // we need do it by casting the Clob to VARCHAR.
    if (parent != null && (parent instanceof ASTEqual || parent instanceof ASTNotEqual) && dbAttr.getType() == Types.CLOB && parent.getOperandCount() == 2 && parent.getOperand(1) instanceof String) {
        Integer size = parent.getOperand(1).toString().length() + 1;
        out.append("CAST(");
        super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
        out.append(" AS VARCHAR(" + size + "))");
    } else {
        super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
    }
}
Also used : ASTEqual(org.apache.cayenne.exp.parser.ASTEqual) ASTNotEqual(org.apache.cayenne.exp.parser.ASTNotEqual) SimpleNode(org.apache.cayenne.exp.parser.SimpleNode)

Example 2 with ASTNotEqual

use of org.apache.cayenne.exp.parser.ASTNotEqual in project cayenne by apache.

the class DerbyQualifierTranslator method processColumnWithQuoteSqlIdentifiers.

@Override
protected void processColumnWithQuoteSqlIdentifiers(DbAttribute dbAttr, Expression pathExp) {
    SimpleNode parent = null;
    if (pathExp instanceof SimpleNode) {
        parent = (SimpleNode) ((SimpleNode) pathExp).jjtGetParent();
    }
    // we need do it by casting the Clob to VARCHAR.
    if (parent != null && (parent instanceof ASTEqual || parent instanceof ASTNotEqual) && dbAttr.getType() == Types.CLOB && parent.getOperandCount() == 2 && parent.getOperand(1) instanceof String) {
        Integer size = parent.getOperand(1).toString().length() + 1;
        out.append("CAST(");
        super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
        out.append(" AS VARCHAR(").append(size).append("))");
    } else {
        super.processColumnWithQuoteSqlIdentifiers(dbAttr, pathExp);
    }
}
Also used : ASTEqual(org.apache.cayenne.exp.parser.ASTEqual) ASTNotEqual(org.apache.cayenne.exp.parser.ASTNotEqual) SimpleNode(org.apache.cayenne.exp.parser.SimpleNode)

Aggregations

ASTEqual (org.apache.cayenne.exp.parser.ASTEqual)2 ASTNotEqual (org.apache.cayenne.exp.parser.ASTNotEqual)2 SimpleNode (org.apache.cayenne.exp.parser.SimpleNode)2