Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

IllegalArgumentException when using clj-record's create function

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".....
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course nothing wrong with clj-record but have a look at ClojureQL also:
https://github.com/LauJensen/clojureql
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, please lets us read your "Clojure in Action" review.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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


It's here.
 
You get good luck from rubbing the belly of a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic