KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > triactive > jdo > store > SetTable


1 /*
2  * Copyright 2002 (C) TJDO.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the TJDO License version 1.0.
6  * See the terms of the TJDO License in the documentation provided with this software.
7  *
8  * $Id: SetTable.java,v 1.2 2002/10/17 21:00:58 pierreg0 Exp $
9  */

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
18 public class SetTable extends FieldTable
19 {
20     private ColumnMapping ownerMapping;
21     private ColumnMapping elementMapping;
22
23
24     protected SetTable(TableMetadata tmd, FieldMetaData fmd, StoreManager storeMgr)
25     {
26         super(tmd, fmd, storeMgr);
27     }
28
29
30     public void initialize()
31     {
32         assertIsUninitialized();
33
34         CollectionMetaData colmd = fmd.getCollectionMetaData();
35         if (colmd == null)
36             throw new JDOUserException("No collection metadata found in " + fmd);
37
38         Class JavaDoc elementType = colmd.getElementType();
39
40         SQLIdentifier ownerColumnName = getBaseColumnNameForType(ownerType);
41         SQLIdentifier elementColumnName = getBaseColumnNameForType(elementType);
42
43         Column ownerColumn = newColumn(ownerType, ownerColumnName, Role.OWNER).setPrimaryKeyPart();
44         Column elementColumn = newColumn(elementType, elementColumnName, Role.ELEMENT).setPrimaryKeyPart();
45
46         elementColumn.setOptions(colmd.getElementColumnOptions());
47
48         ownerMapping = dba.getMapping(ownerColumn);
49         elementMapping = dba.getMapping(elementColumn);
50
51         state = TABLE_STATE_INITIALIZED;
52     }
53
54
55     public ColumnMapping getOwnerMapping()
56     {
57         assertIsInitialized();
58
59         return ownerMapping;
60     }
61
62
63     public ColumnMapping getElementMapping()
64     {
65         assertIsInitialized();
66
67         return elementMapping;
68     }
69 }
70
Popular Tags