Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong CQL query generated when using SET datatype in Cassandra #1031

Open
sohelmk opened this issue Nov 8, 2018 · 2 comments
Open

Wrong CQL query generated when using SET datatype in Cassandra #1031

sohelmk opened this issue Nov 8, 2018 · 2 comments

Comments

@sohelmk
Copy link

sohelmk commented Nov 8, 2018

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)

@sohelmk
Copy link
Author

sohelmk commented Nov 9, 2018

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());

@sohelmk
Copy link
Author

sohelmk commented Nov 9, 2018

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));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant