public class OpenJPAPostgresqlDictionaryPatch extends PostgresDictionary { @Override public SQLBuffer toOperation(String op, SQLBuffer selects, SQLBuffer from, SQLBuffer where, SQLBuffer group, SQLBuffer having, SQLBuffer order, boolean distinct, long start, long end, String forUpdateClause, boolean subselect) { String whereSQL = where.getSQL(); int p = whereSQL.indexOf("LIKE"); int offset = 0; while (p != -1) { where.replaceSqlString(p + offset, p + offset + 4, "ILIKE"); p = whereSQL.indexOf("LIKE", p + 1); offset++; } return super.toOperation(op, selects, from, where, group, having, order, distinct, start, end, forUpdateClause, subselect); } }
typeName = typeName + "(" + getCastStringColumnSize(val) + ")"; String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str);
/** * Overrides SQL formation by replacing COUNT(column) by COUNT(*) when specific conditions are met and * DBDictionary configuration <code>useWildCardForCount</code> is set. */ @Override public void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql, int index) { if (isCountDistinctMultiCols()) { getValue().appendTo(sel, ctx, state, sql, 0); sql.addCastForParam(getOperator(), getValue()); } else super.appendTo(sel, ctx, state, sql, index); if ((ctx.store.getDBDictionary().useWildCardForCount && state.joins.isEmpty()) || !isCountDistinct && isCountMultiColumns){ String s = sql.getSQL(); if (s.startsWith("COUNT(") && s.endsWith(")")) { sql.replaceSqlString("COUNT(".length(), s.length()-1, "*"); } } }
typeName = typeName + "(" + characterColumnSize + ")"; String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str);
typeName = typeName + "(" + getCastStringColumnSize(val) + ")"; String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str);
/** * Overrides SQL formation by replacing COUNT(column) by COUNT(*) when specific conditions are met and * DBDictionary configuration <code>useWildCardForCount</code> is set. */ @Override public void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql, int index) { if (isCountDistinctMultiCols()) { getValue().appendTo(sel, ctx, state, sql, 0); sql.addCastForParam(getOperator(), getValue()); } else super.appendTo(sel, ctx, state, sql, index); if ((ctx.store.getDBDictionary().useWildCardForCount && state.joins.isEmpty()) || !isCountDistinct && isCountMultiColumns){ String s = sql.getSQL(); if (s.startsWith("COUNT(") && s.endsWith(")")) { sql.replaceSqlString("COUNT(".length(), s.length()-1, "*"); } } }
typeName = typeName + "(" + getCastStringColumnSize(val) + ")"; String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str);
typeName = typeName + "(" + getCastStringColumnSize(val) + ")"; String str = "CAST(? AS " + typeName + ")"; buf.replaceSqlString(sqlString.length() - 1, sqlString.length(), str);
/** * Overrides SQL formation by replacing COUNT(column) by COUNT(*) when specific conditions are met and * DBDictionary configuration <code>useWildCardForCount</code> is set. */ @Override public void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql, int index) { if (isCountDistinctMultiCols()) { getValue().appendTo(sel, ctx, state, sql, 0); sql.addCastForParam(getOperator(), getValue()); } else super.appendTo(sel, ctx, state, sql, index); if ((ctx.store.getDBDictionary().useWildCardForCount && state.joins.isEmpty()) || !isCountDistinct && isCountMultiColumns){ String s = sql.getSQL(); if (s.startsWith("COUNT(") && s.endsWith(")")) { sql.replaceSqlString("COUNT(".length(), s.length()-1, "*"); } } }
/** * Overrides SQL formation by replacing COUNT(column) by COUNT(*) when specific conditions are met and * DBDictionary configuration <code>useWildCardForCount</code> is set. */ @Override public void appendTo(Select sel, ExpContext ctx, ExpState state, SQLBuffer sql, int index) { if (isCountDistinctMultiCols()) { getValue().appendTo(sel, ctx, state, sql, 0); sql.addCastForParam(getOperator(), getValue()); } else super.appendTo(sel, ctx, state, sql, index); if ((ctx.store.getDBDictionary().useWildCardForCount && state.joins.isEmpty()) || !isCountDistinct && isCountMultiColumns){ String s = sql.getSQL(); if (s.startsWith("COUNT(") && s.endsWith(")")) { sql.replaceSqlString("COUNT(".length(), s.length()-1, "*"); } } }