             cached-collection-exists? (cached cache gs-collection-exists? db)
             cached-collection-attributes (cached cache gs-collection-attributes db)
             batched-add-feature
-            (with-batch insert-batch insert-batch-size (partial gs-add-feature db proj-fn cached-collection-attributes) flush-fn)]
+            (with-batch insert-batch insert-batch-size (partial gs-add-feature db proj-fn cached-collection-attributes no-insert) flush-fn)]
         (do (when (not (cached-dataset-exists? dataset))
               (gs-create-dataset db dataset)
               (cached-dataset-exists? :reload dataset))

    (catch java.sql.SQLException e
      (log/with-logs ['pdok.featured.projectors :error :error] (j/print-sql-exception-chain e)))))

(defn- flush-all [db proj-fn cache insert-batch update-batch delete-batch]
  "Used for flushing all batches, so entry order is alway new change close"
  (let [cached-collection-attributes (cached cache gs-collection-attributes db)]
    (process-batch delete-batch (partial gs-delete-feature db))
    (flush-batch insert-batch (partial gs-add-feature db proj-fn cached-collection-attributes))
    (flush-batch update-batch (partial gs-update-feature db proj-fn))
    (flush-batch delete-batch (partial gs-delete-feature db))))

(deftype GeoserverProjector [db cache insert-batch insert-batch-size
                             update-batch update-batch-size
                             delete-batch delete-batch-size
                             flush-fn proj-fn no-visualization ndims srid]
  proj/Projector
  (proj/init [this] this)

        update-batch (ref (clojure.lang.PersistentQueue/EMPTY))
        delete-batch-size (or (:delete-batch-size config) (:batch-size config) 10000)
        delete-batch (ref (clojure.lang.PersistentQueue/EMPTY))
        no-insert (ref #{})
        ndims (or (:ndims config) 2)
        srid (or (:srid config) 28992)
        proj-fn (or (:proj-fn config) identity)
        no-visualization (:no-visualization config)
        flush-fn #(flush-all db proj-fn cache insert-batch update-batch delete-batch no-insert)]
    (->GeoserverProjector db cache insert-batch insert-batch-size
                          update-batch update-batch-size
                          delete-batch delete-batch-size no-insert
                          flush-fn proj-fn no-visualization ndims srid)))
