client/prepared and multi.cql

60 views
Skip to first unread message

Derek Troy-West

unread,
Jul 21, 2013, 9:09:09 AM7/21/13
to clojure-...@googlegroups.com
Is the client/prepared macro only applicable to the .cql namespace and not .multi.cql?

I use multi.cql to control my cluster and session construction, and executing normal queries is fine. However, if I attempt something along the lines of:

(client/prepared
  (insert session :some_table {:id "some-id"
                                             :value "some-value"})))

I get an error: 

java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to com.datastax.driver.core.Session
at clojurewerkz.cassaforte.client$prepare.invoke(client.clj:174) ~[classes/:na]
at clojurewerkz.cassaforte.client$execute.doInvoke(client.clj:278) ~[classes/:na]
at clojure.lang.RestFn.invoke(RestFn.java:457) ~[clojure-1.5.1.jar:na]
at clojurewerkz.cassaforte.multi.cql$execute_.invoke(cql.clj:17) ~[classes/:na]
at clojurewerkz.cassaforte.multi.cql$insert.doInvoke(cql.clj:132) ~[classes/:na]
at clojure.lang.RestFn.invoke(RestFn.java:439) ~[clojure-1.5.1.jar:na]

My session is constructed fine, I can use it to execute normal queries. 
I'm relatively new to Clojure, so it's possible I'm doing something stupid.

If client/prepared is not applicable to .multi.cql - how can I use multi and prepared statements? I see there is an option to force-prepared-queries when creating the cluster, that's a little brute force but probably acceptable.

Thanks for your help,
 Derek

Alex P

unread,
Jul 21, 2013, 9:30:28 AM7/21/13
to clojure-...@googlegroups.com

Hi Derek,


If client/prepared is not applicable to .multi.cql - how can I use multi and prepared statements? I see there is an option toforce-prepared-queries when creating the cluster, that's a little brute force but probably acceptable.

We actually do recommend using prepared queries for everything, unless you're generating tons of absolutely different 
queries during runtime, which should not be the case for majority of applications. Prepared queries usually yield a better
performance.

However, you're right, and there was a bug that was preventing (client/prepared) to be used with multi-cql, it's fixed now,
I've pushed a new version to Clojars. You can use version 1.1.0 (https://clojars.org/clojurewerkz/cassaforte) that contains 
these fixes.

If you run into some other issue, let us know, we'll do our best to fix it shortly.

Thanks for checking out Cassaforte! 

--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-cassandra/bebbfd96-107c-45e0-8ea0-0bacac9f7b1a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Derek Troy-West

unread,
Jul 21, 2013, 9:36:15 AM7/21/13
to clojure-...@googlegroups.com
Thanks for the quick reply and advice Alex, much appreciated.

I've Enjoyed using Cassaforte so far - have been using the excellent Datastax CQL driver w/ Java recently but this is much more fun!

Alex P

unread,
Jul 21, 2013, 9:58:47 AM7/21/13
to clojure-...@googlegroups.com
Nice to hear that! :)
Just to make sure we're also working on some docs that are planned to be released as a handbook for all languages you can use with Cassandra: http://clojurecassandra.info 

But I hope you've already seen those guides.

Sent from Mailbox for iPhone


Reply all
Reply to author
Forward
0 new messages