1 22 package org.jboss.ejb3.test.regression; 23 24 import javax.persistence.JoinColumn; 25 import javax.persistence.CascadeType; 26 import javax.persistence.OneToMany; 27 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; 28 import javax.persistence.FetchType; 29 import javax.persistence.Id; 30 import javax.persistence.Entity; 31 import javax.persistence.Table; 32 import java.io.Serializable ; 33 import java.util.Collection ; 34 import java.util.ArrayList ; 35 36 41 @Entity 42 @Table(name="account") 43 public class Account implements Serializable 44 { 45 private long id; 46 private Collection <AccountName> names = new ArrayList <AccountName>(); 47 48 @Id @GeneratedValue(strategy=GenerationType.IDENTITY) 49 public long getId() 50 { 51 return id; 52 } 53 54 public void setId(long id) 55 { 56 this.id = id; 57 } 58 59 @OneToMany(mappedBy = "account", cascade = CascadeType.ALL, fetch=FetchType.EAGER) 60 @JoinColumn(name = "accountId") 61 public Collection <AccountName> getNames() 62 { 63 return names; 64 } 65 66 public void setNames(Collection <AccountName> names) 67 { 68 this.names = names; 69 } 70 } 71 | Popular Tags |