Skip to content

Oracle NoSQL Storage of Embedded Objects

xamry edited this page Jul 11, 2013 · 3 revisions

Columns of embeddable objects are stored in a way similar to regular columns, with the exception that minor keys have two components: (1) Embedded column name, and (2) Column name in embeddable class.

Let's add an embeddable attribute to our Person class, persist person object and see how it's stored in OracleNoSQL.

Person.java

@Entity
@Table(name = "PERSON", schema = "HR_Store@oracle_nosql_pu")
@IndexCollection(columns = {@Index(name = "userName") },{@Index(name = "age") })
public class Person
{
    @Id
    @Column(name = "PERSON_ID")
    private String personId;

    @Column(name = "PERSON_NAME")
    private String personName;

    @Column(name = "AGE")
    private Integer age;

    @Embedded
    private Office office;
    
    //Getters and setters
}

Office.java

@Embeddable
public class Office
{
    @Column
    private int officeId;

    @Column
    private String companyName;

    @Column
    private String location;

    //Getters and Setters
}

Here is how data will look like when person entity is persisted.

/PERSON/1/ - /PERSON_NAME        ---> John Smith
/PERSON/1/ - /AGE                ---> 32
/PERSON/1/ - /office/officeId    ---> L1
/PERSON/1/ - /office/companyName ---> Impetus
/PERSON/1/ - /office/location    ---> San Jose
Previous Home Next
Clone this wiki locally