1 19 20 21 package org.apache.cayenne.jpa.map; 22 23 import java.util.ArrayList ; 24 import java.util.Collection ; 25 26 import javax.persistence.JoinTable; 27 28 import org.apache.cayenne.util.TreeNodeChild; 29 30 public class JpaJoinTable { 31 32 protected String name; 33 protected String catalog; 34 protected String schema; 35 36 protected Collection <JpaJoinColumn> joinColumns; 37 protected Collection <JpaJoinColumn> inverseJoinColumns; 38 protected Collection <JpaUniqueConstraint> uniqueConstraints; 39 40 public JpaJoinTable() { 41 42 } 43 44 public JpaJoinTable(JoinTable annotation) { 45 name = annotation.name(); 46 catalog = annotation.catalog(); 47 schema = annotation.schema(); 48 49 getJoinColumns(); 50 for (int i = 0; i < annotation.joinColumns().length; i++) { 51 joinColumns.add(new JpaJoinColumn(annotation.joinColumns()[i])); 52 } 53 54 getInverseJoinColumns(); 55 for (int i = 0; i < annotation.inverseJoinColumns().length; i++) { 56 inverseJoinColumns.add(new JpaJoinColumn(annotation.inverseJoinColumns()[i])); 57 } 58 59 getUniqueConstraints(); 60 for (int i = 0; i < annotation.uniqueConstraints().length; i++) { 61 uniqueConstraints.add(new JpaUniqueConstraint( 62 annotation.uniqueConstraints()[i])); 63 } 64 } 65 66 public String getCatalog() { 67 return catalog; 68 } 69 70 public void setCatalog(String catalog) { 71 this.catalog = catalog; 72 } 73 74 public String getName() { 75 return name; 76 } 77 78 public void setName(String name) { 79 this.name = name; 80 } 81 82 public String getSchema() { 83 return schema; 84 } 85 86 public void setSchema(String schema) { 87 this.schema = schema; 88 } 89 90 @TreeNodeChild(type = JpaJoinColumn.class) 91 public Collection <JpaJoinColumn> getInverseJoinColumns() { 92 if (inverseJoinColumns == null) { 93 inverseJoinColumns = new ArrayList <JpaJoinColumn>(); 94 } 95 96 return inverseJoinColumns; 97 } 98 99 @TreeNodeChild(type = JpaJoinColumn.class) 100 public Collection <JpaJoinColumn> getJoinColumns() { 101 if (joinColumns == null) { 102 joinColumns = new ArrayList <JpaJoinColumn>(); 103 } 104 105 return joinColumns; 106 } 107 108 @TreeNodeChild(type = JpaUniqueConstraint.class) 109 public Collection <JpaUniqueConstraint> getUniqueConstraints() { 110 if (uniqueConstraints == null) { 111 uniqueConstraints = new ArrayList <JpaUniqueConstraint>(); 112 } 113 114 return uniqueConstraints; 115 } 116 } 117 | Popular Tags |