title: Inserting db rows with Korma
body: <p>I have a DB table that uses the following schema:</p>
  
  <pre><code>CREATE TABLE users
  (id SERIAL PRIMARY KEY,
    username TEXT UNIQUE NOT NULL,
    password TEXT NOT NULL,
    email TEXT NOT NULL,
    admin BOOLEAN NOT NULL,
    active BOOLEAN NOT NULL,
    created DATE NOT NULL);
  </code></pre>
  
  <p>I use Korma by defining a <code>users</code> entity</p>
  
  <pre><code>(defentity users
             (has-many tips))
  </code></pre>
  
  <p>And I try to seed values using the following functions:</p>
  
  <pre><code>(defn make-user-vals [username pass email]
    "Creates an active, non-admin user"
    {:username username, 
     :password (crypt/encrypt pass), 
     :email email,
     :admin false,
     :active true,
     :created (java.util.Date.)})
  
  (defn seed-users! []
    (insert ent/users
      (values 
        (users/make-user-vals "admin" "f00b4r" "foo@example.com"))))
  </code></pre>
  
  <p><code>(seed-users!)</code> fails with the following (not really informative to my eyes) message: </p>
  
  <pre><code>Failure to execute query with SQL:
  INSERT INTO users (username, password, email, admin, active, created) VALUES (?, ?, ?, FALSE, TRUE, ?)  ::  [admin $2a$10$AVdxz9HvYOyszhcXVrTVi.oBcbz9EZVfGZYNUI3iDMb0hj3igvpEy foo@example.com #&lt;Date Wed Feb 15 21:59:10 CET 2012&gt;]
  ClassCastException java.lang.RuntimeException cannot be cast to java.sql.SQLException  clojure.java.jdbc/print-sql-exception (jdbc.clj:350)
  </code></pre>
  
  <p>Any idea why?</p>
  
  <p>(if that helps, querying the DB works, so it does not look like a connection problem)</p>
  
  <p>Thanks!</p>