1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.model.FieldMetaData; 14 import com.triactive.jdo.model.MapMetaData; 15 import javax.jdo.JDOUserException; 16 17 18 public class MapTable extends FieldTable 19 { 20 private ColumnMapping ownerMapping; 21 private ColumnMapping keyMapping; 22 private ColumnMapping valueMapping; 23 24 25 protected MapTable(TableMetadata tmd, FieldMetaData fmd, StoreManager storeMgr) 26 { 27 super(tmd, fmd, storeMgr); 28 } 29 30 31 public void initialize() 32 { 33 assertIsUninitialized(); 34 35 MapMetaData mmd = fmd.getMapMetaData(); 36 if (mmd == null) 37 throw new JDOUserException("No map metadata found in " + fmd); 38 39 Class keyType = mmd.getKeyType(); 40 Class valueType = mmd.getValueType(); 41 42 SQLIdentifier ownerColumnName = getBaseColumnNameForType(ownerType); 43 SQLIdentifier keyColumnName = getBaseColumnNameForType(keyType); 44 SQLIdentifier valueColumnName = getBaseColumnNameForType(valueType); 45 46 Column ownerColumn = newColumn(ownerType, ownerColumnName, Role.OWNER).setPrimaryKeyPart(); 47 Column keyColumn = newColumn(keyType, keyColumnName, Role.KEY).setPrimaryKeyPart(); 48 Column valueColumn = newColumn(valueType, valueColumnName, Role.VALUE); 49 50 keyColumn.setOptions(mmd.getKeyColumnOptions()); 51 valueColumn.setOptions(mmd.getValueColumnOptions()); 52 53 if (mmd.allowsNullValues()) 54 valueColumn.setNullable(); 55 56 ownerMapping = dba.getMapping(ownerColumn); 57 keyMapping = dba.getMapping(keyColumn); 58 valueMapping = dba.getMapping(valueColumn); 59 60 state = TABLE_STATE_INITIALIZED; 61 } 62 63 64 public ColumnMapping getOwnerMapping() 65 { 66 assertIsInitialized(); 67 68 return ownerMapping; 69 } 70 71 72 public ColumnMapping getKeyMapping() 73 { 74 assertIsInitialized(); 75 76 return keyMapping; 77 } 78 79 80 public ColumnMapping getValueMapping() 81 { 82 assertIsInitialized(); 83 84 return valueMapping; 85 } 86 } 87 | Popular Tags |