사용자 도구

사이트 도구


java:jpa:elementcollection

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
java:jpa:elementcollection [2014/09/24 15:54]
kwon37xi
java:jpa:elementcollection [2015/01/13 10:48]
kwon37xi [@ElementCollection에 조건 주기]
줄 1: 줄 1:
 ====== JPA @ElementCollection ====== ====== JPA @ElementCollection ======
 +
 +  * [[http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection|JPA ElementCollection]]
 +
 +===== 기본 =====
 +  * Parent<code java>
 +@Entity
 +public class Employee {
 +  @Id
 +  @Column(name="EMP_ID")
 +  private long id;
 +  ...
 +  @ElementCollection
 +  @CollectionTable(
 +        name="PHONE",
 +        joinColumns=@JoinColumn(name="OWNER_ID")
 +  )
 +  private List<Phone> phones;
 +  ...
 +}
 +</code>
 +  * Children<code java>
 +@Embeddable
 +public class Phone {
 +  private String type;
 +  private String areaCode;
 +  @Column(name="P_NUMBER")
 +  private String number;
 +  ...
 +}
 +</code>
 +
 +
  
 ===== @ElementCollection에 조건 주기 ===== ===== @ElementCollection에 조건 주기 =====
java/jpa/elementcollection.txt · 마지막으로 수정됨: 2015/01/13 10:48 저자 kwon37xi