1 21 package oracle.toplink.essentials.internal.ejb.cmp3.metadata.columns; 23 24 import javax.persistence.JoinColumn; 25 26 import oracle.toplink.essentials.internal.helper.DatabaseField; 27 28 34 public class MetadataJoinColumn { 35 protected DatabaseField m_pkField; 36 protected DatabaseField m_fkField; 37 38 public static final String DEFAULT_NAME = ""; 39 public static final String DEFAULT_TABLE = ""; 40 public static final String DEFAULT_COLUMN_DEFINITION = ""; 41 public static final String DEFAULT_REFERENCED_COLUMN_NAME = ""; 42 43 public static final boolean DEFAULT_UNIQUE = false; 44 public static final boolean DEFAULT_NULLABLE = true; 45 public static final boolean DEFAULT_UPDATABLE = true; 46 public static final boolean DEFAULT_INSERTABLE = true; 47 48 51 public MetadataJoinColumn() { 52 m_pkField = new DatabaseField(); 53 m_pkField.setName(DEFAULT_REFERENCED_COLUMN_NAME); 54 55 m_fkField = new DatabaseField(); 56 m_fkField.setName(DEFAULT_NAME); 57 m_fkField.setTableName(DEFAULT_TABLE); 58 m_fkField.setUnique(DEFAULT_UNIQUE); 59 m_fkField.setNullable(DEFAULT_NULLABLE); 60 m_fkField.setUpdatable(DEFAULT_UPDATABLE); 61 m_fkField.setInsertable(DEFAULT_INSERTABLE); 62 m_fkField.setColumnDefinition(DEFAULT_COLUMN_DEFINITION); 63 } 64 65 69 public MetadataJoinColumn(JoinColumn joinColumn) { 70 this(); 71 72 if (joinColumn != null) { 73 m_pkField.setName(joinColumn.referencedColumnName()); 75 76 m_fkField.setName(joinColumn.name()); 78 m_fkField.setTableName(joinColumn.table()); 79 m_fkField.setUnique(joinColumn.unique()); 80 m_fkField.setNullable(joinColumn.nullable()); 81 m_fkField.setUpdatable(joinColumn.updatable()); 82 m_fkField.setInsertable(joinColumn.insertable()); 83 m_fkField.setColumnDefinition(joinColumn.columnDefinition()); 84 } 85 } 86 87 90 public DatabaseField getForeignKeyField() { 91 return m_fkField; 92 } 93 94 97 public DatabaseField getPrimaryKeyField() { 98 return m_pkField; 99 } 100 101 104 public boolean isForeignKeyFieldNotSpecified() { 105 return m_fkField.getName().equals(""); 106 } 107 108 111 public boolean isPrimaryKeyFieldNotSpecified() { 112 return m_pkField.getName().equals(""); 113 } 114 115 118 public boolean loadedFromXML() { 119 return false; 120 } 121 } 122 | Popular Tags |