protected PreparedStatement createStatement(boolean withKeys) throws SQLException {
        boolean addBatches = !configuration.getUseLiterals();
        listeners.preRender(context);
        SQLSerializer serializer = createSerializer();
        PreparedStatement stmt = null;
        if (batches.isEmpty()) {
            serializer.serializeMerge(metadata, entity, keys, columns, values, subQuery);
            context.addSQL(createBindings(metadata, serializer));
            listeners.rendered(context);

            listeners.prePrepare(context);
            stmt = prepareStatementAndSetParameters(serializer, withKeys);
            context.addPreparedStatement(stmt);
            listeners.prepared(context);
        } else {
            serializer.serializeMerge(metadata, entity,
                    batches.get(0).getKeys(), batches.get(0).getColumns(),
                    batches.get(0).getValues(), batches.get(0).getSubQuery());
            context.addSQL(createBindings(metadata, serializer));
            listeners.rendered(context);

            stmt = prepareStatementAndSetParameters(serializer, withKeys);

            // add first batch
            if (addBatches) {
                stmt.addBatch();
            }

            // add other batches
            for (int i = 1; i < batches.size(); i++) {
                SQLMergeBatch batch = batches.get(i);
                listeners.preRender(context);
                serializer = createSerializer();
                serializer.serializeMerge(metadata, entity, batch.getKeys(), batch.getColumns(), batch.getValues(), batch.getSubQuery());
                context.addSQL(createBindings(metadata, serializer));
                listeners.rendered(context);

                setParameters(stmt, serializer.getConstants(), serializer.getConstantPaths(), metadata.getParams());
                if (addBatches) {
                    stmt.addBatch();
                }
            }
        }
        return stmt;
    }
Execute the clause and return the generated keys as a ResultSet

@return result set with generated keys
querydsl-sql/src/main/java/com/querydsl/sql/dml/SQLMergeClause.java