Skip to content

Relationship Between Class

Otávio Santana edited this page Aug 7, 2013 · 10 revisions

In the Cassandra is not recommended make relationship between the columns family, like one to one or many to many etc, but it’s possible insert all information in only column family, like a big table, ( if you want relationship maybe you should use relational data base). The family column grows in lazy mode, makes column when there is need, so in the same column there can be lines with different sizes, for example with one and with ten lines. For do this resource it’s necessary only create the class and embedded in the main class, bellow the exemple for that.

The Main Class

@Entity(nome = "person")
public class Person implements Serializable {

private static final long serialVersionUID = 3L;

@Id
private Long id;

@Column(nome = "name")
private String name;

@Column(nome = "born")
private Integer year;

@Embedded
private Address address;

//getter and setter
}

Embedded classes

public class Address implements Serializable {
private static final long serialVersionUID = 1L;

@Column(nome="state")
private String state;

@Column(nome="cyte")
private String city;

@Column(nome="street")
private String street;

@Column(nome="cep")
private String cep;

//getter and setter
}
Something went wrong with that request. Please try again.