wood burning stoves 2.0*
The moose likes Clojure and the fly likes IllegalArgumentException when using clj-record's create function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Languages » Clojure
Bookmark "IllegalArgumentException when using clj-record Watch "IllegalArgumentException when using clj-record New topic
Author

IllegalArgumentException when using clj-record's create function

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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: 14688
    
  16

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: 3479

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: 14688
    
  16

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: 3479

Cool, please lets us read your "Clojure in Action" review.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

John Todd wrote:Cool, please lets us read your "Clojure in Action" review.

It's here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalArgumentException when using clj-record's create function