protected Collection<PreparedStatement> createStatements(boolean withKeys) throws SQLException {
        boolean addBatches = !configuration.getUseLiterals();
        listeners.preRender(context);

        if (subQueryBuilder != null) {
            subQuery = subQueryBuilder.select(values.toArray(new Expression[0])).clone();
            values.clear();
        }

        Map<String, PreparedStatement> stmts = new HashMap<>();

        // add first batch
        SQLSerializer serializer = createSerializer();
        serializer.serializeInsert(metadata, entity, batches.get(0).getColumns(), batches
                .get(0).getValues(), batches.get(0).getSubQuery());
        PreparedStatement stmt = prepareStatementAndSetParameters(serializer, withKeys);
        if (addBatches) {
            stmt.addBatch();
        }
        stmts.put(serializer.toString(), stmt);
        context.addSQL(createBindings(metadata, serializer));
        listeners.rendered(context);

        // add other batches
        for (int i = 1; i < batches.size(); i++) {
            SQLInsertBatch batch = batches.get(i);

            listeners.preRender(context);
            serializer = createSerializer();
            serializer.serializeInsert(metadata, entity, batch.getColumns(),
                    batch.getValues(), batch.getSubQuery());
            context.addSQL(createBindings(metadata, serializer));
            listeners.rendered(context);

            stmt = stmts.get(serializer.toString());
            if (stmt == null) {
                stmt = prepareStatementAndSetParameters(serializer, withKeys);
                stmts.put(serializer.toString(), stmt);
            } else {
                setParameters(stmt, serializer.getConstants(), serializer.getConstantPaths(),
                        metadata.getParams());
            }
            if (addBatches) {
                stmt.addBatch();
            }
        }

        return stmts.values();
    }
Execute the clause and return the generated key with the type of the
given path. If no rows were created, or the referenced column is not a
generated key, null is returned. Otherwise, the key of the first row is
returned.

@param <T>
@param path path for key
@return generated keys
querydsl-sql/src/main/java/com/querydsl/sql/dml/AbstractSQLInsertClause.java