Complex class

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

Bellow a example using enum value and embedded class

Main Class

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

private static final long serialVersionUID = 3L;

@Id
private Long id;

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

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

@Enumerated
@Column(nome="sex")
private Sex sex;

@Embedded
private Address address;

//getter and setter
}

Enum value

public enum Sex {
MALE,FEMALE 
}

Embedded class

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;

//getter and setter
}