support for UUID in automated mapping #95

wants to merge 2 commits into


None yet

4 participants


I added some lines to support UUIDs as well in the automated mapping.
Since the ColumnListMutation<C> putColumn(C columnName, UUID value, Integer ttl) method already accepts UUIDs, I see no further work to be done.
I also tested it positively.


I just hit the UnsupportedOperationException when trying to use UUID with the cool Mapping feature.
I was very surprised to see that a request to fix had already been made and the fix was already done!

Great job guys!

Is there any guess as to when this fix will be available in a release?

Thanks guys!


It would be nice if you could also update the tests in to reflect the new mapping.

To update the tests you will need to add a UUID to

Otherwise great job.


I took your code fix and ran a test with it. It works pretty well but there is one small thing that I am observing that I don't know if we need to fix.

When I create a bean like:

public class TenantBean
* The id of the tenant.
private UUID tenantId;

 * The name of the tenant.
private String name;


And I have the column family defined:

TenantId uuid PRIMARY KEY,
Name text

When I try to use the Mapping like this:

ColumnFamily CF_USER = new ColumnFamily(
"Users", // Column Family Name
StringSerializer.get(), // Key Serializer
StringSerializer.get()); // Column Serializer

    Mapping<TenantBean> mapper = Mapping.make(TenantBean.class);

    // writing a bean
    MutationBatch mutationBatch = keyspace.prepareMutationBatch();

    ColumnListMutation<String> columnListMutation =
        mutationBatch.withRow(UserManagementColumnFamilies.CF_TENANT, tenantBean.getTenantId());

    mapper.fillMutation(tenantBean, columnListMutation);

It gives me an error that says:

BadRequestException: [host=, latency=3(4), attempts=1] InvalidRequestException(why:(String didn't validate.) [MyKeySpace][Tenants][TenantId] failed validation)

To see what it is trying to do, I changed my default_validator on the Tenants column family like this:

TenantId uuid PRIMARY KEY,
Name text
) WITH default_validation = BytesType;

Then I ran it again (I am trying to insert a Tenant to the column family), I noticed the following:

[default@MyKeySpace] list Tenants;
Using default limit of 100

Using default column limit of 100

RowKey: 8780602d-2a15-4fe9-b41a-b3b9debec7f2
=> (column=TenantId, value=8780602d2a154fe9b41ab3b9debec7f2, timestamp=1344887503906001)
=> (column=Name, value=SomeTenant, timestamp=1344887503906001)

See how it added the extra column TenantId. Since the default_validator is UTF8 by default, when the mapper added the new column for TenantId (Which I don't know why it does.. feels like it shoudln't), it failed in the default validator because it wanted a UTF8 instead of the UUID.

Seems like maybe we need to fix also where ever it tried to generate these columns?


I just tried it myself and I come to the same result. It does not matter which type the row key is. I tried it also for a String type row key. There is always a second row like your TenantId. I switched to manually mapping the columns which works correctly.

We need a fix in the mapping code, i think


Thank you for verifying.

I already opened an issue:


@elandau elandau closed this Nov 8, 2012
@mosche mosche pushed a commit to gini/astyanax that referenced this pull request Nov 12, 2012
moritz mack FIXING #95, skip row key when mapping f9ba004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment