can null value be set by using jpql when cassandra?
i want to update table's column to null value by using jpql . how can i do it? my db is cassandra.
There is nothing like null in cassandra as everything has a byte[] representation. What you could do is to set explicitly as "null" string value and handle it in your application by string equals comparision with "null" !
-Vivek
yes, iee.
by the way, when entity saving, if i set the property to null,the column can be set to nothing?
sample:
entity.setName(null); em.persist()entity;
can i clear the column's data by the up actions?
Yes, by default Kundera omit such columns. But if you try: entity.setName("null"); // null as string.
It should work for you.
"can i clear the column's data by the up actions? "
Can you please explain more on this?
-Vivek
entity.setName("null"); →it will help me clear the data value in name column of the table?
others, when i set UUID column to null like fellowing, the column not be update to null in db.
entity.setId(null);//Id is UUID type
As i mentioned earlier, null and "null" are two different assignment. if you assign null, it won't be persisted, as cassandra does not understand a null. But if you assign it a value as "null", which is essentially a string value. It will work. Now for UUID type, it is not of String type. So i recommend, if you want to store your row key as "null" ! ( Which is highly unlikely not permissible in RDBMS even), then change your data type to UTF8Type from UUIDType.
-Vivek
yes, i see.
but in cql , like "delete
yes, i see.
but in cql , like "delete columnName from tableName"can clear the data of the cloumn. how can do the same thing by using jpql?
Simply invoke, for example;
Delete p from Person P;
Have a look at: https://github.com/impetus-opensource/Kundera/blob/trunk/kundera-cassandra/src/test/java/com/impetus/client/persistence/UpdateDeleteNamedQueryTest.java
for reference.
-Vivek
in the sample, the full row (entity) is deleted. i just want to delete some columns of the row. how can i do it in jpql?
Thrift API does not support it. Only possible way is via executing CQL query, which is via em.createNativeQuery.
-Vivek
in new verion of kundera 2.3,i think i can use jdbc driver, when i use jdbc driver, can i do it ?
as you know, if i use jpql and cql in the application, there may be have some problems when update data.
pls refer: https://github.com/impetus-opensource/Kundera/issues/154
Still cassandra jdbc driver is not very mature and set of features supported by Kundera simply may not work using JDBC. So we are planning it for 2.4
However, 2.3 release will be upgraded to cassandra 1.2 for thrift API. Also other issues raised around usage "update query with set parameter" and "support of count in JPQL" will be in with 2.3
-Vivek
thanks for your infos!
others, in Thrift API , i think the sepc clomns can be removed.
sample: http://abel-perez.com/cassandra-delete-column-example
Hmm. Looks like i missed on it then. keeping it open for 2.4
-Vivek
thank you very much! by the way, when kundera 2.4 will release? can you tell me your plan?
We did not finalize on date yet. But should be in a month or so.
I guess as an alternative, still you can use CQL native query support to achieve such features via Kundera
-Vivek