public SQLSerializer(Configuration conf, boolean dml) { super(conf.getTemplates()); this.configuration = conf; this.templates = conf.getTemplates(); this.dml = dml; }
private long executeBatch(PreparedStatement stmt) throws SQLException { if (configuration.getUseLiterals()) { return stmt.executeUpdate(); } else if (configuration.getTemplates().isBatchCountViaGetUpdateCount()) { stmt.executeBatch(); return stmt.getUpdateCount(); } else { long rv = 0; for (int i : stmt.executeBatch()) { rv += i; } return rv; } }
/** * Add the current state of bindings as a batch item * * @return */ public SQLMergeClause addBatch() { if (!configuration.getTemplates().isNativeMerge()) { throw new IllegalStateException("batch only supported for databases that support native merge"); } batches.add(new SQLMergeBatch(keys, columns, values, subQuery)); columns.clear(); values.clear(); keys.clear(); subQuery = null; return this; }
@Override public String toString() { if (queryString == null) { StringBuilder builder = new StringBuilder(); for (Map.Entry<String, String> entry : values.entrySet()) { builder.append(entry.getKey()).append("=").append(entry.getValue()); builder.append(";"); } if (configuration.getUseLiterals() || forSession) { queryString = "set query_band='" + configuration.getTemplates().escapeLiteral(builder.toString()) + (forSession ? "' for session" : "' for transaction"); parameter = null; } else { queryString = "set query_band=?" + (forSession ? " for session" : " for transaction"); parameter = builder.toString(); } } return queryString; }
/** * @param paths * @return */ public PostgresQuery of(RelationalPath<?>... paths) { StringBuilder builder = new StringBuilder(" of "); for (RelationalPath<?> path : paths) { if (builder.length() > 4) { builder.append(", "); } builder.append(getConfiguration().getTemplates().quoteIdentifier(path.getTableName())); } return addFlag(Position.END, builder.toString()); }
@Override public long execute() { if (configuration.getTemplates().isNativeMerge()) { return executeNativeMerge(); } else { return executeCompositeMerge(); } }
if (stage == Stage.SELECT && !Null.class.isInstance(constant) && configuration.getTemplates().isWrapSelectParameters()) { String typeName = configuration.getTypeNameForCast(constant.getClass()); Expression type = Expressions.constant(typeName);
context = startContext(connection, metadata, entity); try { if (configuration.getTemplates().isNativeMerge()) { PreparedStatement stmt = null; if (batches.isEmpty()) {
QueryModifiers originalModifiers = queryMixin.getMetadata().getModifiers(); try { if (configuration.getTemplates().isCountViaAnalytics() && queryMixin.getMetadata().getGroupBy().isEmpty()) { List<RT> results;