           username   (sec/session-username (-> ctx :request :session))
           profile_id (sha1/gen-key :profile profile)]
       (when (and entity_id timestamp)
-        (when (seq
-                (first
-                  (db/execute session (hayt/select :entities (hayt/where [[= :id entity_id]])))))
+        (when (seq (entity/get-by-id session entity_id))
           (let [query-profile (-> profile
                                  (assoc :user_id username)
                                  (update-stringified-lists

  Returns a list of vectors of two elements, the first being the attribute key,
  and the second the value.
  The keys are expanded like <association name>_<associated item index>_<attribute name>"
  (let [association-name   (name (:name    association))
        association-schema (:schema  association)]
    (apply concat
    (map-indexed
      (fn [index item-string]
         (let [item-name         (str association-name "_" index)
               named-association (assoc association :name item-name)]
           (if (empty? association-schema)
             [ item-name item-string ]
             (explode-nested-item named-association item-string))))
      items))))


          method       (:request-method request)
          route-params (:route-params request)
          entity_id    (:entity_id route-params)
          entity       (entity/get-by-id session entity_id)]
      (case method
        :post (not (nil? entity))
        :get (let [items (db/execute session (hayt/select :profiles (hayt/where [[= :entity_id entity_id]])))]
