Impetus / kundera

A JPA 2.1 compliant Polyglot Object-Datastore Mapping Library for NoSQL Datastores.Please subscribe to:

Home Page:http://groups.google.com/group/kundera-discuss/subscribe

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong CQL query generated when using SET datatype in Cassandra

sohelmk opened this issue · comments

Hi,
I am using Kundera with Cassadra db, but unable to insert an entity that has one of datatype as Set[String]. When I checked the logs the CQL generated is wrong. Set are supposed to be given as {""}.
Please let me know if any workaround. Note the language is scala, most examples online show java.util.set. There is built-in datatype in scala called set that is interoperable with java.

[error] c.i.c.c.CassandraClientBase - Error while executing query INSERT INTO "groups"("created_by","group_image","access_type","labels","updated_timestamp","created_timestamp","updated_by","description","group_account","group_name","group_id") VALUES(35bb8547-e0d0-42a9-b761-c2b91cea56fd,0x62646231346662653037366636623934343434633636306533366134303031353166323666633666,'public',Set(test),'1541546600000','1541546600000',bbcc1f44-c6cf-4de2-9a77-1dfe0f754bf2,'dd','STANDARD','dd',35bb8547-e0d0-42a9-b761-c2b91cea56fd)
[error] c.c.d.RespondentGroupsDAOImpl - addGroup Error :
com.impetus.kundera.KunderaException: com.impetus.kundera.KunderaException: InvalidRequestException(why:line 1:316 no viable alternative at input 'Set' (...) VALUES(35bb8547-e0d0-42a9-b761-c2b91cea56fd,0x62646231346662653037366636623934343434633636306533366134303031353166323666633666,'public',[Set]...))
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:180)
at com.consultengine.daos.RespondentGroupsDAOImpl$.addGroup(RespondentGroupsDAO.scala:261)
at com.consultengine.services.UserService.addGroup(UserService.scala:151)
at com.consultengine.controllers.v1.GroupsController.$anonfun$addGroup$1(GroupsController.scala:37)
at scala.Function1.$anonfun$andThen$1(Function1.scala:52)
at play.api.mvc.ActionBuilderImpl.invokeBlock(Action.scala:482)

Here is relevent scala code:

Entity class:

@entity
@table(name = "groups", schema = "cedb@cassandra_pu")
class GroupDO{
@id
@column(name = "group_id")
var gid: UUID = UUID.randomUUID

@column(name = "group_name")
var gname: String = "name"

@column(name = "access_type")
var gtype: String = "type"

@column(name = "description")
var descr: String = "descr"

@column(name = "group_image")
var gimage = Array.fillByte(0)

@column(name = "labels")
var labels:Set[String] =Set("test")

@column(name = "group_account")
var grouAccount: String = "gaccount"

@column(name = "created_timestamp")
var ctime:Timestamp = new Timestamp(System.currentTimeMillis());

And the CQL of group table

CREATE TABLE IF NOT EXISTS groups (group_id UUID, group_name TEXT,description TEXT, group_account TEXT, group_image blob,access_type TEXT,labels set, created_timestamp Timestamp, created_by UUID,updated_timestamp Timestamp, updated_by UUID ,PRIMARY KEY (group_id));