1 19 20 package org.apache.cayenne.jpa.map; 21 22 import java.util.ArrayList ; 23 import java.util.Collection ; 24 25 import javax.persistence.OneToMany; 26 27 import org.apache.cayenne.util.TreeNodeChild; 28 29 public class JpaOneToMany extends JpaRelationship { 30 31 protected String mappedBy; 32 protected Collection <JpaJoinColumn> joinColumns; 33 protected JpaJoinTable joinTable; 34 protected String orderBy; 35 protected String mapKey; 36 37 public JpaOneToMany() { 38 39 } 40 41 public JpaOneToMany(OneToMany annotation) { 42 if (!Void.TYPE.equals(annotation.targetEntity())) { 43 this.targetEntityName = annotation.targetEntity().getName(); 44 } 45 46 for (int i = 0; i < annotation.cascade().length; i++) { 47 if (cascade == null) { 48 cascade = new JpaCascade(); 49 } 50 cascade.getCascades().add(annotation.cascade()[i]); 51 } 52 53 fetch = annotation.fetch(); 54 mappedBy = annotation.mappedBy(); 55 } 56 57 @Override 58 public boolean isToMany() { 59 return true; 60 } 61 62 @TreeNodeChild(type = JpaJoinColumn.class) 63 public Collection <JpaJoinColumn> getJoinColumns() { 64 if (joinColumns == null) { 65 joinColumns = new ArrayList <JpaJoinColumn>(); 66 } 67 return joinColumns; 68 } 69 70 public JpaJoinTable getJoinTable() { 71 return joinTable; 72 } 73 74 public void setJoinTable(JpaJoinTable joinTable) { 75 this.joinTable = joinTable; 76 } 77 78 public String getOrderBy() { 79 return orderBy; 80 } 81 82 public void setOrderBy(String orderBy) { 83 this.orderBy = orderBy; 84 } 85 86 public String getMappedBy() { 87 return mappedBy; 88 } 89 90 public void setMappedBy(String mappedBy) { 91 this.mappedBy = mappedBy; 92 } 93 94 95 public String getMapKey() { 96 return mapKey; 97 } 98 99 100 public void setMapKey(String mapKey) { 101 this.mapKey = mapKey; 102 } 103 } 104 | Popular Tags |