Skip to content

Using Compound keys with Kundera

mevivs edited this page Oct 31, 2012 · 12 revisions

Unstructured Data? Scalability is not an issue, use NOSQL! Compound keys is one way to achieve faster search over denormalized data. Kundera(2.2 release on-wards) supports compound key.

How to use:

You can define compound key with entity definition using @EmbeddedId annotation, like:

@Entity
@Table(name="User", schema="KunderaExamples@mongoTest")
public class PrimeUser
{
    
    @EmbeddedId
    private CompoundKey key;

Here key has to be an Embeddable entity:

@Embeddable
public class CompoundKey
{
    @Column private String userId;
    @Column private int tweetId;
    @Column private UUID timeLineId;

Performing any CRUD operation is similar the way, for single primary key.

You can refer here for examples:

**Note:**Current trunk branch supports it for MongoDB and cassandra. Feature will be available with 2.2 release.

Clone this wiki locally