| Author |
IllegalArgumentException when using clj-record's create function
|
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
I'm trying clj-record with Postgresql 8.2. I have a table called "users", and a domain class called "user". When using the "create" function on "user", the following exception is thrown : java.lang.IllegalArgumentException: Record does not exist (NO_SOURCE_FILE:0)
Actually, the record is successfully inserted...
The "create" function inserts and retrieves the inserted record. It looks like there's a problem with the id used for retrieving the record. I tried calling the "insert" function directly, and it returns nil. My "users" tables has the following layout:
Has anybody any idea why the record is not correctly fetched ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
Solved ! The "insert" function calls "id-query-for", which is a multimethod. For postgresql, the function is :
which means that the id column must be called "id", and that it must be "serial". My table layout looks like that :
I don't quite like the fact that the column id is fixed to "id".....
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
Of course nothing wrong with clj-record but have a look at ClojureQL also:
https://github.com/LauJensen/clojureql
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Thanks John, I'll have a look at it. Actually I'm reading Clojure In Action, and the chapter on data storage is using clj-record and MySql. I decided to use Postgresql instead, as it's already installed on my machine, and I started to run into troubles...
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3359
|
|
|
Cool, please lets us read your "Clojure in Action" review.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
John Todd wrote:Cool, please lets us read your "Clojure in Action" review.
It's here.
|
 |
 |
|
|
subject: IllegalArgumentException when using clj-record's create function
|
|
|