HBase column families

53 views
Skip to first unread message

Charly Lizarralde

unread,
May 14, 2015, 10:26:23 AM5/14/15
to kundera...@googlegroups.com
Hi, I have an Entity that has several attributes and I would like to persist them different column families? How should I do this ? 

Now I am using hbase-v2 driver of Kundera 2.17 and HBase 1.0

Cheers,
Charly

Pragalbh garg

unread,
May 15, 2015, 2:31:44 AM5/15/15
to kundera...@googlegroups.com
Hi,
You can do that by using @SecondaryTables annotation over your entity. And then you can mention it in @Column annotation in the 'table' property over your attribute. For illustration-
 
@Table(name = "HBASE_TABLE", schema = "HBaseNew@secTableTest")
@SecondaryTables({ @SecondaryTable(name = "HBASE_SECONDARY_TABLE"), @SecondaryTable(name = "t_country") })
@Entity
public class HbaseSecondaryTableEntity
{

    /** The object id. */
    @Id
    @Column(name = "OBJECT_ID")
    private String objectId;

    /** The name. */
    @Column(name = "NAME")
    private String name;

    /** The age. */
    @Column(name = "AGE", table = "HBASE_SECONDARY_TABLE")
    private int age;

    /** The country. */
    @Column(name = "Country", table = "t_country")
    private String country;
//setters and getters
}

This will create 2 more column families apart from the default column family namely 'HBASE_SECONDARY_TABLE' and 't_country'.
The column 'country' will be stored in the column family 't_country'.
For further knowledge, please refer this test case.
https://github.com/impetus-opensource/Kundera/blob/d37a85fa6334ed1e81091c27c6a84df2cbaf568c/src/kundera-hbase/kundera-hbase-v2/src/test/java/com/impetus/client/hbase/secondarytable/HbaseSecondaryTableTest.java

Hope that helps!
Team Kundera

Charly Lizarralde

unread,
May 15, 2015, 6:25:29 PM5/15/15
to kundera...@googlegroups.com
Thanks! I am going to try it and let you know...

Pragalbh garg

unread,
May 19, 2015, 9:35:47 AM5/19/15
to kundera...@googlegroups.com
Hi Charly,
Did the solution work for you?
If you have any queries/feedbacks regarding Kundera, please share with us.

Regards
Team Kundera

Charly Lizarralde

unread,
Jun 2, 2015, 10:47:25 AM6/2/15
to kundera...@googlegroups.com
Hey! Didn't tried it yet but will definitely do.
Reply all
Reply to author
Forward
0 new messages