/** * Return the preferred {@link Types} constant for the given * {@link JavaTypes} or {@link JavaSQLTypes} constant. */ public int getJDBCType(int metaTypeCode, boolean lob) { return getJDBCType(metaTypeCode, lob, 0, 0); }
/** * Make any necessary changes to the given column name to make it valid * for the current DB. The column name will be made unique for the * specified table. */ public DBIdentifier getValidColumnName(DBIdentifier name, Table table) { return getValidColumnName(name, table, true); }
/** * Replace SQL '?' with CAST string if required by DB platform * @param oper * @param val */ public void addCastForParam(String oper, Val val) { if (_sql.charAt(_sql.length() - 1) == '?') { String castString = _dict.addCastAsType(oper, val); if (castString != null) _sql.replace(_sql.length() - 1, _sql.length(), castString); } }
/** * Return the preferred database type name for the given column's type * from {@link Types}. */ public String getTypeName(Column col) { if (!DBIdentifier.isEmpty(col.getTypeIdentifier())) return appendSize(col, toDBName(col.getTypeIdentifier())); if (col.isAutoAssigned() && autoAssignTypeName != null) return appendSize(col, autoAssignTypeName); return appendSize(col, getTypeName(col.getType())); }
/** * Return the preferred database type name for the given column's type * from {@link Types}. */ public String getTypeName(Column col) { if (!StringUtils.isEmpty(col.getTypeName())) return appendSize(col, col.getTypeName()); if (col.isAutoAssigned() && autoAssignTypeName != null) return appendSize(col, autoAssignTypeName); return appendSize(col, getTypeName(col.getType())); }
if (requiresTargetForDelete) { sql.append("DELETE "); SQLBuffer deleteTargets = getDeleteTargets(sel); sql.append(deleteTargets); sql.append(" FROM "); Collection<String> selectedTables = getSelectTableAliases(sel); if (selectedTables.size() == 1 && supportsSubselect && allowsAliasInBulkClause) { SQLBuffer from; if (sel.getFromSelect() != null) from = getFromSelect(sel, false); else from = getFrom(sel, false); appendUpdates(sel, store, sql, params, updateParams, allowsAliasInBulkClause); String tableName = getFullName(table, false); appendUpdates(sel, store, sql, params, updateParams, false); return sql; sel.select(pks[0]); sql.append(tableName); appendUpdates(sel, store, sql, params, updateParams, false); sql.append(" WHERE "). append(pks[0]).append(" IN (").
boolean rhsxml = rhs.getXPath() != null; if (lhsxml || rhsxml) { appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); return; || (lhs.isConstant() && rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
/** * Add the primary key column to the given table and return it. */ protected Column addPrimaryKeyColumn(Table table) { DBDictionary dict = _conf.getDBDictionaryInstance(); Column pkColumn = table.addColumn(dict.getValidColumnName (getPrimaryKeyColumnIdentifier(), table)); pkColumn.setType(dict.getPreferredType(Types.TINYINT)); pkColumn.setJavaType(JavaTypes.INT); return pkColumn; }
|| (lhs.isConstant() || rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
buf.append(val.toString()); buf.append(mid); buf.append(getTypeName(type)); appendLength(buf, type); buf.append(post);
appendSelectRange(buf, start, end, subselect); if (distinct) buf.append(" DISTINCT"); if (range && rangePosition == RANGE_POST_DISTINCT) appendSelectRange(buf, start, end, subselect); buf.append(" GROUP BY ").append(group); if (having != null && !having.isEmpty()) { assertSupport(supportsHaving, "SupportsHaving"); buf.append(" HAVING ").append(having); buf.append(" ORDER BY ").append(order); if (range && rangePosition == RANGE_POST_SELECT) appendSelectRange(buf, start, end, subselect); if (forUpdateClause != null) buf.append(" ").append(forUpdateClause); if (range && rangePosition == RANGE_POST_LOCK) appendSelectRange(buf, start, end, subselect); return buf;
/** * If this dictionary supports XML type, * use this method to append xml predicate. * * @param buf the SQL buffer to write the comparison * @param op the comparison operation to perform * @param lhs the left hand side of the comparison * @param rhs the right hand side of the comparison */ public void appendXmlComparison(SQLBuffer buf, String op, FilterValue lhs, FilterValue rhs, boolean lhsxml, boolean rhsxml) { super.appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); if (lhsxml && rhsxml) appendXmlComparison2(buf, op, lhs, rhs); else if (lhsxml) appendXmlComparison1(buf, op, lhs, rhs); else appendXmlComparison1(buf, op, rhs, lhs); }
/** * Return the portion of the select statement between the SELECT keyword * and the FROM keyword. */ protected SQLBuffer getSelects(Select sel, boolean distinctIdentifiers, boolean forUpdate) { // append the aliases for all the columns SQLBuffer selectSQL = new SQLBuffer(this); List aliases; if (distinctIdentifiers) aliases = sel.getIdentifierAliases(); else aliases = sel.getSelectAliases(); Object alias; for (int i = 0; i < aliases.size(); i++) { alias = aliases.get(i); if (alias instanceof String) { alias = getNamingUtil().convertAlias((String)alias); } appendSelect(selectSQL, alias, sel, i); if (i < aliases.size() - 1) selectSQL.append(", "); } return selectSQL; }
protected String appendSize(Column col, String typeName) { // foxpro does not like unsized column declarations. if (col.getSize() == 0) { if ("CHARACTER".equals(typeName)) col.setSize(240); else if ("NUMERIC".equals(typeName)) col.setSize(19); } return super.appendSize(col, typeName); }
/** * Append SQL for the given numeric value to the buffer, casting as needed. */ protected void appendNumericCast(SQLBuffer buf, FilterValue val) { if (val.isConstant()) appendCast(buf, val, Types.NUMERIC); else val.appendTo(buf); }
/** * Return the portion of the select statement between the SELECT keyword * and the FROM keyword. */ protected SQLBuffer getSelects(Select sel, boolean distinctIdentifiers, boolean forUpdate) { // append the aliases for all the columns SQLBuffer selectSQL = new SQLBuffer(this); List aliases; if (distinctIdentifiers) aliases = sel.getIdentifierAliases(); else aliases = sel.getSelectAliases(); Object alias; for (int i = 0; i < aliases.size(); i++) { alias = aliases.get(i); appendSelect(selectSQL, alias, sel, i); if (i < aliases.size() - 1) selectSQL.append(", "); } return selectSQL; }
if (requiresTargetForDelete) { sql.append("DELETE "); SQLBuffer deleteTargets = getDeleteTargets(sel); sql.append(deleteTargets); sql.append(" FROM "); Collection<String> selectedTables = getSelectTableAliases(sel); if (selectedTables.size() == 1 && supportsSubselect && allowsAliasInBulkClause) { SQLBuffer from; if (sel.getFromSelect() != null) from = getFromSelect(sel, false); else from = getFrom(sel, false); appendUpdates(sel, store, sql, params, updateParams, allowsAliasInBulkClause); String tableName = getFullName(table, false); appendUpdates(sel, store, sql, params, updateParams, false); return sql; sel.select(pks[0]); sql.append(tableName); appendUpdates(sel, store, sql, params, updateParams, false); sql.append(" WHERE "). append(pks[0]).append(" IN (").
boolean rhsxml = rhs.getXPath() != null; if (lhsxml || rhsxml) { appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); return; || (lhs.isConstant() && rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
/** * Return the preferred database type name for the given column's type * from {@link Types}. */ public String getTypeName(Column col) { if (!DBIdentifier.isEmpty(col.getTypeIdentifier())) return appendSize(col, toDBName(col.getTypeIdentifier())); if (col.isAutoAssigned() && autoAssignTypeName != null) return appendSize(col, autoAssignTypeName); return appendSize(col, getTypeName(col.getType())); }
/** * Add the primary key column to the given table and return it. */ protected Column addPrimaryKeyColumn(Table table) { DBDictionary dict = _conf.getDBDictionaryInstance(); Column pkColumn = table.addColumn(dict.getValidColumnName (getPrimaryKeyColumnIdentifier(), table)); pkColumn.setType(dict.getPreferredType(Types.TINYINT)); pkColumn.setJavaType(JavaTypes.INT); return pkColumn; }