I have a UserBean.java defined:
public class UserBean
private String userId;
private String firstName;
private String lastName;
I have a column family defined as:
ColumnFamily<String, String> CF_USER = new ColumnFamily<String, String>(
"Users", // Column Family Name
StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer
I have the ColumnFamily DDL defined in CQL:
CREATE TABLE Users
UserId text PRIMARY KEY,
I create a user like this:
String keyspaceName = "MyKeyspace";
Keyspace keyspace = cluster.getKeyspace(keyspaceName);
Mapping<UserBean> mapper = Mapping.make(UserBean.class);
// writing a bean
MutationBatch mutationBatch = keyspace.prepareMutationBatch();
ColumnListMutation<String> columnListMutation =
What I see in the database:
=> (column=FirstName, value=SomeFirstName, timestamp=1344887503881001)
=> (column=LastName, value=SomeLastName, timestamp=1344887503881001)
=> (column=UserId, firstname.lastname@example.org, timestamp=1344887503881001)
Please note the last column was dynamically added.
Since the UserId has the @Id annotation in the UserBean class, it should just show up as the RowKey and NOT be added as an extra column added dynamically.
It gets worse if you use a UUID type for your @Id in the bean as it will try to add a column dynamically that will fail validation because the default validation is UTF8, which is what I want for all my columns, just not the RowKey.
Elandau, what is your take on this getting into the next release?
mjensen, thank you for the detailed explanation. We agree with your point and are looking into changing it.
Fixed in new entity mapping code. https://github.com/Netflix/astyanax/wiki/Entity-persister