01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: SetTable.java,v 1.2 2002/10/17 21:00:58 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.model.FieldMetaData;
14: import com.triactive.jdo.model.CollectionMetaData;
15: import javax.jdo.JDOUserException;
16:
17: public class SetTable extends FieldTable {
18: private ColumnMapping ownerMapping;
19: private ColumnMapping elementMapping;
20:
21: protected SetTable(TableMetadata tmd, FieldMetaData fmd,
22: StoreManager storeMgr) {
23: super (tmd, fmd, storeMgr);
24: }
25:
26: public void initialize() {
27: assertIsUninitialized();
28:
29: CollectionMetaData colmd = fmd.getCollectionMetaData();
30: if (colmd == null)
31: throw new JDOUserException(
32: "No collection metadata found in " + fmd);
33:
34: Class elementType = colmd.getElementType();
35:
36: SQLIdentifier ownerColumnName = getBaseColumnNameForType(ownerType);
37: SQLIdentifier elementColumnName = getBaseColumnNameForType(elementType);
38:
39: Column ownerColumn = newColumn(ownerType, ownerColumnName,
40: Role.OWNER).setPrimaryKeyPart();
41: Column elementColumn = newColumn(elementType,
42: elementColumnName, Role.ELEMENT).setPrimaryKeyPart();
43:
44: elementColumn.setOptions(colmd.getElementColumnOptions());
45:
46: ownerMapping = dba.getMapping(ownerColumn);
47: elementMapping = dba.getMapping(elementColumn);
48:
49: state = TABLE_STATE_INITIALIZED;
50: }
51:
52: public ColumnMapping getOwnerMapping() {
53: assertIsInitialized();
54:
55: return ownerMapping;
56: }
57:
58: public ColumnMapping getElementMapping() {
59: assertIsInitialized();
60:
61: return elementMapping;
62: }
63: }
|