Operator IN
When use "in" key word using cassandra 1.2 (kundera 2.5) with the next query, for example:
Query query = em.createQuery("SELECT * FROM ColumnFamily where KEY IN ( 12345,123456); query.getResultList();
The following error happend: "Condition in is not suported for query on row key! "
Can anyone help me get it working ? Thanks
Hi, Currently Kundera does not support IN clause in JPQL way(work in progress). But you can execute a native cql3 query as:
Query query = em.createNativeQuery("SELECT * FROM ColumnFamily where KEY IN ( 12345,123456)"); query.getResultList();
-Vivek
I used createNativeQuery, and the following error happend:
InvalidRequestException(why:Cannot execute/prepare CQL3 statement since the CQL has been set to CQL2(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+)
I've been researching on the error but have not found anything useful. Any help? Thanks
You need to set for cql version to 3.0.0 . Given below are various ways to set this.
- You can set it while creating entity manager factory as:
propertyMap = new HashMap();
propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
EntityManagerFactory emf = Persistence.createEntityManagerFactory(persisntenceUnit, propertyMap);
- Another alternative is, set it via Em as
Map<String, Client> clientMap = (Map<String, Client>) em.getDelegate();
ThriftClient tc = (ThriftClient) clientMap.get("your pu name");
tc.setCqlVersion(CassandraConstants.CQL_VERSION_3_0);
- Else you can also pass it as property as, create a property file(say, kunderaTest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<clientProperties>
<datastores>
<dataStore>
<name>cassandra</name>
<connection>
<properties>
<property name="cql.version" value="3.0.0"></property>
</properties>
</connection>
</dataStore>
</datastores>
</clientProperties>
And then configure it in persistence.xml as:
<property name="kundera.client.property" value="kunderaTest.xml" />
Hope it helps.
-Vivek
Is this working for you?
-Vivek
Yes, it has worked. Thank you very much for helping
Ok. Great!
Using Kundera for?
-Vivek