Quantcast
Channel: How to store array of objects in Cassandra - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How to store array of objects in Cassandra

$
0
0

In cassandra DB I am planning to store an array-of-object. What is the best way to do that. object mapping to Data mapping with model class in java.

Class Test{
   @Column(name = "id")
   int id,
   @Column(name = "name")
   String name,
   Address[] address

 class Address{
   String add1,
   String city,
   String state 
  }
}

Should I put all(id, name, add1, city, state) in one table by adding columns to same keyspace with add1, city, state also? or add new table for address Or any other options..

I have tried to add TYPE But throwing error as: "Error from server: code=2200 [Invalid query] message="A user type cannot contain non-frozen UDTs" From the error and type syntax I have used keyword 'frozen', but not luck. Altering table also gives similar Error something like : "mismatched input 'frozen' expecting EOF"

Also, What if I have to save column of type 'String[ ]' As it is not custom type like Address[]. it is of String or text.? Do we need to just add alter statement? if so how it looks like


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>