         [:td (escape-html (:message x))]])
      ]]))
 
+(defn update-and-persist
+  "Using Korma: Changes the :randomNumber of a number of world entities.
+  Persists the changes to sql then returns the updated entities"
+  [queries]
+  (let [results (map #(assoc % :randomNumber (inc (rand-int 9999))) (run-queries queries))]
+    (doseq [{:keys [id randomNumber]} results]
+      (update world
+              (set-fields {:randomNumber randomNumber})
+              (where {:id id})))
+    results))
+
+(defn json-serialization
+  "Test 1: JSON serialization"
+  [request]
+  (bootstrap/json-response {:message "Hello, World!"}))
+
+(defn single-query-test
+  "Test 2: Single database query"
+  [request]
+  (bootstrap/json-response (first (run-queries 1))))
+
+(defn multiple-queries-test
+  "Test 3: Multiple database queries"
+  [request]
+  (-> request
+      (sanitize-queries-param)
+      (run-queries)
+      (bootstrap/json-response)))
 
 (defn fortune-test
   "Test 4: Fortunes"

            [clojure.data.json :as json]
            [clojure.java.jdbc :as jdbc]))


(defn json-serialization
  "Test 1: JSON serialization"
  [request]
  (bootstrap/json-response {:message "Hello, World!"}))


;; MySQL connection
(defdb mysql-db
  (mysql {
    :classname "com.mysql.jdbc.Driver"
    :subprotocol "mysql"
    :subname "//127.0.0.1:3306/hello_world"
    :user "benchmarkdbuser"
    :password "benchmarkdbpass"
    ;;OPTIONAL KEYS

  [request]
  (ring-resp/response "Hello, World!"))

;; Define route handlers
(defroutes routes
  [[
  [  "/plaintext" {:get plaintext}]
  [  "/json"      {:get json-serialization}]
  [  "/db"        {:get single-query-test}]
  [  "/queries"   {:get multiple-queries-test}]
  [  "/fortunes"  {:get fortune-test}]
  [  "/updates"   {:get db-updates}]]])


(def service
