Skip to content

Embeddables support in Kudu

Devender Yadav edited this page Mar 8, 2017 · 4 revisions

Support for Embeddable objects has been added to Kundera-Kudu in 3.8 release. Embeddable columns are stored parallel to columns in primary table.

EmbeddablePerson.java

@Entity
@Table(name = "PERSON_EMBED_KUDU", schema = "kudutest@kudu")
public class EmbeddablePerson
{
    @Id
    private String personId;

    private String personName;
    
    @Embedded
    private Address address;

}

Address.java

@Embeddable
public class Address
{
    private String street;

    private String city;

    private String country;
}

The above embeddable Address is stored in Table: PERSON_EMBED_KUDU as follows:

Columns:

personId : String (Primary Key = true)
personName: String
street: String
city: String
country: String

Check test-case for more details.

Support for EmbeddableId

Embeddable objects can also be used as a primary key to define composite primary key in Kudu.

Metrics.java

@Entity
@Table(name = "METRICS", schema = "kudutest@kudu")
public class Metrics
{
    @EmbeddedId
    private MetricsId id;

    private double value;
}

MetricsId.java

@Embeddable
public class MetricsId
{
    private String host;

    private String metric;

    private long time;
}

Table: METRICS is created in Kudu as follows:

Columns:

host: String (Primary Key = true)
metric: String (Primary Key = true)
time: Int64 (Primary Key = true)
value: Double

Check test-case for more details.

Clone this wiki locally