0

I have a case class like this:

case class Address(id String, location String)
case class Person(id String, name String, address Option[Address])

Now I want to store these case class in cassandra table. I am working with Lagom Persistence. So I created Read side Processor to do that task. I wrote the following under setGlobalPrepare method:

session.executeWrite("""
| CREATE TYPE Address(
| id text, 
| location text)""".stripMargin)

session.executeCreateTable("""
| CREATE TABLE Person(
| id text,
| name text,
| address frozen<Address>,
| PRIMARY KEY((id),name)
| )""".stripMargin)

But this showing an error that "UnresolvedUserTypeException: cannot resolve user type testdatabase.id" (testdatabase is the keyspace)and same for name of Address UDT.

First i Thought it was because of all the execution of the command are running in future so I tried using map to wait for the main table to be created before the UDT but didnt work. All tables are showing in cassandra but i am getting this error and i am not able to insert anything to it.

Need Help....

Akhil Vijayan
  • 93
  • 1
  • 1
  • 8
  • Hi Akhil, this seems like an error on your CQL. I recommend you tune that first using a Cassandra client (`cqlsh`, `DBeaver Enterprise`, `DevCenter`) first. If you don't want to install a Cassandra server on your machine, you can start lagom in dev mode using `runAll` and connect to the Lagom-managed cassandra instance on `localhost:4000`. – ignasi35 Oct 15 '17 at 10:42

1 Answers1

0

the type creation should also be invoked within a "executeCreateTable" and you should add a space between "frozen" and the UDT-Name.

session.executeCreateTable("""
   CREATE TYPE IF NOT EXISTS Address(
        id text, 
        location text
   )"""
)
session.executeCreateTable("""
    CREATE TABLE IF NOT EXISTS Person(
        id text,
        name text,
        address frozen <Address>,
        PRIMARY KEY((id),name)
    )"""
)

Hope that helps/works.

Regards