 
 
 (defmacro defentity [name properties &
-                     {:keys [datastore-entity-name]
-                      :or {datastore-entity-name (unqualified-name name)}}]
+                     {:keys [kind]
+                      :or {kind (unqualified-name name)}}]
   (let [key-property-name (first (filter #(= (:tag (meta %)) :key) properties))
         key-property (if key-property-name (keyword (str key-property-name)) nil)]
     `(defrecord ~name ~properties
        EntityProtocol
        (get-key-object [this#]
-         (get-key-object-helper this# ~key-property ~datastore-entity-name))
+         (get-key-object-helper this# ~key-property ~kind))
        (get-key-object [this# parent#]
-         (get-key-object-helper this# ~key-property ~datastore-entity-name :parent parent#))
+         (get-key-object-helper this# ~key-property ~kind :parent parent#))
        (save! [this#]
-         (save!-helper this# ~datastore-entity-name))
+         (save!-helper this# ~kind))
        (save! [this# parent#]
-         (save!-helper this# ~datastore-entity-name :parent parent#)))))
+         (save!-helper this# ~kind :parent parent#)))))
 
 
 ;;; Note that the code relies on the API's implicit transaction tracking, and

         :else v)))


(defn get-key-object-helper [entity-record key-property datastore-entity-name &
                             {:keys [parent]}]
  (let [entity-record-metadata (meta entity-record)
        metadata-key-value (when entity-record-metadata (:key entity-record-metadata))



(defn retrieve [entity-record-type key-value &
                {:keys [parent kind]
                 :or {kind (unqualified-name (.getName entity-record-type))}}]
  (let [key-object (if parent
                       (KeyFactory/createKey (get-key-object parent)
                                             kind
                                             (coerce-key-value-type key-value))
                       (KeyFactory/createKey kind
                                             (coerce-key-value-type key-value)))
        entity (.get (get-datastore-service) key-object)
        raw-properties (into {} (.getProperties entity))
