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.TableGenerator; 27 28 33 public class JpaTableGenerator { 34 35 protected String name; 36 protected String table; 37 protected String catalog; 38 protected String schema; 39 protected String pkColumnName; 40 protected String valueColumnName; 41 protected String pkColumnValue; 42 protected int initialValue = 0; 43 protected int allocationSize = 50; 44 45 protected Collection <JpaUniqueConstraint> uniqueConstraints; 46 47 public JpaTableGenerator() { 48 49 } 50 51 public JpaTableGenerator(TableGenerator annotation) { 52 name = annotation.name(); 53 table = annotation.table(); 54 catalog = annotation.catalog(); 55 schema = annotation.schema(); 56 pkColumnName = annotation.pkColumnName(); 57 valueColumnName = annotation.valueColumnName(); 58 pkColumnValue = annotation.pkColumnValue(); 59 initialValue = annotation.initialValue(); 60 allocationSize = annotation.allocationSize(); 61 62 getUniqueConstraints(); 63 for (int i = 0; i < annotation.uniqueConstraints().length; i++) { 64 uniqueConstraints.add(new JpaUniqueConstraint( 65 annotation.uniqueConstraints()[i])); 66 } 67 } 68 69 public int getAllocationSize() { 70 return allocationSize; 71 } 72 73 public void setAllocationSize(int allocationSize) { 74 this.allocationSize = allocationSize; 75 } 76 77 public String getCatalog() { 78 return catalog; 79 } 80 81 public void setCatalog(String catalog) { 82 this.catalog = catalog; 83 } 84 85 public int getInitialValue() { 86 return initialValue; 87 } 88 89 public void setInitialValue(int initialValue) { 90 this.initialValue = initialValue; 91 } 92 93 101 public String getName() { 102 return name; 103 } 104 105 public void setName(String name) { 106 this.name = name; 107 } 108 109 public String getPkColumnName() { 110 return pkColumnName; 111 } 112 113 public void setPkColumnName(String pkColumnName) { 114 this.pkColumnName = pkColumnName; 115 } 116 117 public String getPkColumnValue() { 118 return pkColumnValue; 119 } 120 121 public void setPkColumnValue(String pkColumnValue) { 122 this.pkColumnValue = pkColumnValue; 123 } 124 125 public String getSchema() { 126 return schema; 127 } 128 129 public void setSchema(String schema) { 130 this.schema = schema; 131 } 132 133 143 public String getTable() { 144 return table; 145 } 146 147 public void setTable(String table) { 148 this.table = table; 149 } 150 151 public String getValueColumnName() { 152 return valueColumnName; 153 } 154 155 public void setValueColumnName(String valueColumnName) { 156 this.valueColumnName = valueColumnName; 157 } 158 159 public Collection <JpaUniqueConstraint> getUniqueConstraints() { 160 if (uniqueConstraints == null) { 161 uniqueConstraints = new ArrayList <JpaUniqueConstraint>(2); 162 } 163 164 return uniqueConstraints; 165 } 166 } 167 | Popular Tags |