1 19 20 package org.apache.cayenne.jpa.map; 21 22 import java.sql.Types ; 23 24 import javax.persistence.TemporalType; 25 26 import org.apache.cayenne.dba.TypesMapping; 27 import org.apache.cayenne.util.TreeNodeChild; 28 29 public class JpaId extends JpaAttribute { 30 31 protected JpaColumn column; 32 protected JpaGeneratedValue generatedValue; 33 protected TemporalType temporal; 34 protected JpaTableGenerator tableGenerator; 35 protected JpaSequenceGenerator sequenceGenerator; 36 37 40 public int getDefaultJdbcType() { 41 42 if (getTemporal() != null) { 43 44 if (TemporalType.TIMESTAMP == getTemporal()) { 45 return Types.TIMESTAMP; 46 } 47 else if (TemporalType.DATE == getTemporal()) { 48 return Types.DATE; 49 } 50 else { 51 return Types.TIME; 52 } 53 } 54 else { 55 return TypesMapping.getSqlTypeByJava(getPropertyDescriptor().getType()); 56 } 57 } 58 59 @TreeNodeChild 60 public JpaColumn getColumn() { 61 return column; 62 } 63 64 public void setColumn(JpaColumn column) { 65 this.column = column; 66 } 67 68 @TreeNodeChild 69 public JpaGeneratedValue getGeneratedValue() { 70 return generatedValue; 71 } 72 73 public void setGeneratedValue(JpaGeneratedValue generatedValue) { 74 this.generatedValue = generatedValue; 75 } 76 77 public TemporalType getTemporal() { 78 return temporal; 79 } 80 81 public void setTemporal(TemporalType temporal) { 82 this.temporal = temporal; 83 } 84 85 public JpaSequenceGenerator getSequenceGenerator() { 86 return sequenceGenerator; 87 } 88 89 public void setSequenceGenerator(JpaSequenceGenerator sequenceGenerator) { 90 this.sequenceGenerator = sequenceGenerator; 91 } 92 93 public JpaTableGenerator getTableGenerator() { 94 return tableGenerator; 95 } 96 97 public void setTableGenerator(JpaTableGenerator tableGenerator) { 98 this.tableGenerator = tableGenerator; 99 } 100 } 101 | Popular Tags |