/** * Converts a collection of objects that implement the getSQLString method into a String, * with the given comma string between each element. * * @param c the Collection of SQLStringable objects * @param comma the String to use as a separator between elements * @return a String representation */ protected static String collectionToSQLString(Collection<? extends SQLStringable> c, String comma) { return collectionToSQLString(c, null, comma); }
/** * Converts a collection of objects that implement the getSQLString method into a String, * with the given comma string between each element. * * @param c the Collection of SQLStringable objects * @param comma the String to use as a separator between elements * @return a String representation */ protected static String collectionToSQLString(Collection<? extends SQLStringable> c, String comma) { return collectionToSQLString(c, null, comma); }
/** Convert this Query into a SQL String query, without regard to the other members of the * UNION. * * @return this Query in String form */ public String getSQLStringNoUnion() { return (explain ? "EXPLAIN " : "") + "SELECT " + (distinct ? "DISTINCT " : "") + collectionToSQLString(select, ", ") + (from.isEmpty() ? "" : " FROM " + collectionToSQLString(from, ", ")) + (where.isEmpty() ? "" : " WHERE " + collectionToSQLString(where, " AND ")) + (groupBy.isEmpty() ? "" : " GROUP BY " + collectionToSQLString(groupBy, ", ") + (having.isEmpty() ? "" : " HAVING " + collectionToSQLString(having, " AND "))) + (orderBy.isEmpty() ? "" : " ORDER BY " + collectionToSQLString(orderBy, ", ")) + (limit == 0 ? "" : " LIMIT " + limit + (offset == 0 ? "" : " OFFSET " + offset)); }
/** Convert this Query into a SQL String query, without regard to the other members of the * UNION. * * @return this Query in String form */ public String getSQLStringNoUnion() { return (explain ? "EXPLAIN " : "") + "SELECT " + (distinct ? "DISTINCT " : "") + collectionToSQLString(select, ", ") + (from.isEmpty() ? "" : " FROM " + collectionToSQLString(from, ", ")) + (where.isEmpty() ? "" : " WHERE " + collectionToSQLString(where, " AND ")) + (groupBy.isEmpty() ? "" : " GROUP BY " + collectionToSQLString(groupBy, ", ") + (having.isEmpty() ? "" : " HAVING " + collectionToSQLString(having, " AND "))) + (orderBy.isEmpty() ? "" : " ORDER BY " + collectionToSQLString(orderBy, ", ")) + (limit == 0 ? "" : " LIMIT " + limit + (offset == 0 ? "" : " OFFSET " + offset)); }
/** * Convert this Query into a SQL String query, without regard to the other members of the the * UNION, with an extra field in the SELECT list. * * @param extraSelect an extra String to put into the select list * @return this Query in String form */ public String getSQLStringForPrecomputedTable(String extraSelect) { return (explain ? "EXPLAIN " : "") + "SELECT " + (distinct ? "DISTINCT " : "") + collectionToSQLString(select, Collections.singleton(extraSelect), ", ") + (from.isEmpty() ? "" : " FROM " + collectionToSQLString(from, ", ")) + (where.isEmpty() ? "" : " WHERE " + collectionToSQLString(where, " AND ")) + (groupBy.isEmpty() ? "" : " GROUP BY " + collectionToSQLString(groupBy, ", ") + (having.isEmpty() ? "" : " HAVING " + collectionToSQLString(having, " AND "))) + (orderBy.isEmpty() ? "" : " ORDER BY " + collectionToSQLString(orderBy, ", ")) + (limit == 0 ? "" : " LIMIT " + limit + (offset == 0 ? "" : " OFFSET " + offset)); }
/** * Convert this Query into a SQL String query, without regard to the other members of the the * UNION, with an extra field in the SELECT list. * * @param extraSelect an extra String to put into the select list * @return this Query in String form */ public String getSQLStringForPrecomputedTable(String extraSelect) { return (explain ? "EXPLAIN " : "") + "SELECT " + (distinct ? "DISTINCT " : "") + collectionToSQLString(select, Collections.singleton(extraSelect), ", ") + (from.isEmpty() ? "" : " FROM " + collectionToSQLString(from, ", ")) + (where.isEmpty() ? "" : " WHERE " + collectionToSQLString(where, " AND ")) + (groupBy.isEmpty() ? "" : " GROUP BY " + collectionToSQLString(groupBy, ", ") + (having.isEmpty() ? "" : " HAVING " + collectionToSQLString(having, " AND "))) + (orderBy.isEmpty() ? "" : " ORDER BY " + collectionToSQLString(orderBy, ", ")) + (limit == 0 ? "" : " LIMIT " + limit + (offset == 0 ? "" : " OFFSET " + offset)); }