I created a table in Cassandra from this code :
@Entity
public class UserEvent {
@Id
private String userId;
@Column
private String col1;
@Column
private String col2;
....
manager = new DefaultEntityManager.Builder<UserEvent, String>()
.withEntityType(UserEvent.class)
.withKeyspace(keyspace)
.withColumnFamily("UserEvent")
.build();
manager.createStorage(null);
After adding few rows using manager , if I go to CQL3 and do select*, i see this :
cqlsh:demo> select * from "UserEvent";
key | column1 | value
-----+---------+----------------------------------
A2 | col1 | 0x61
A2 | col2 | 0xe6919fea82b2eaa88ae1a393e9b688
A3 | col1 | 0x61
A3 | col2 | 0xe98fabe5bda7eca5a8e7a5b5efa1b3
A50 | col1 | 0x62
So what I think, is happening is, Astyanax, FLATTENS my datamodel, to convert a individual row into M rows, where row-key is original-key+columnName.
I confirmed my suspicion by doing describe :
cqlsh:demo> describe TABLE "UserEvent";
CREATE TABLE "UserEvent" (
key text,
column1 text,
value blob,
PRIMARY KEY ((key), column1)
)
Now the question is , how do I stop astyanax from messing around with my data model. What I want is, something that produces output like :
cqlsh:demo> create table "MyUserEvent" ( key text, col1 text, col2 text, PRIMARY KEY (key) );
cqlsh:demo> insert into "MyUserEvent" (key,col1,col2) values ('key1','col11','col12');
cqlsh:demo> select * from "MyUserEvent";
key | col1 | col2
------+-------+-------
key1 | col11 | col12
key2 | col21 | col22
PS : Flattening as in Vertical flattening. :)