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: FieldTable.java,v 1.3 2003/05/24 03:33:13 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.ClassNotPersistenceCapableException;
14: import com.triactive.jdo.model.FieldMetaData;
15: import java.lang.reflect.Field;
16: import javax.jdo.JDOFatalInternalException;
17: import javax.jdo.JDOUnsupportedOptionException;
18:
19: abstract class FieldTable extends JDOBaseTable {
20: protected final FieldMetaData fmd;
21: protected final Field field;
22: protected final Class ownerType;
23:
24: protected FieldTable(TableMetadata tmd, FieldMetaData fmd,
25: StoreManager storeMgr) {
26: super (tmd, storeMgr);
27:
28: this .fmd = fmd;
29: this .field = fmd.getField();
30: this .ownerType = fmd.getClassMetaData().getPCClass();
31:
32: switch (fmd.getPersistenceModifier()) {
33: case FieldMetaData.PERSISTENCE_MODIFIER_NONE:
34: default:
35: throw new JDOFatalInternalException(
36: "Invalid persistence modifier on field "
37: + fmd.getName());
38:
39: case FieldMetaData.PERSISTENCE_MODIFIER_TRANSACTIONAL:
40: break;
41:
42: case FieldMetaData.PERSISTENCE_MODIFIER_PERSISTENT:
43: break;
44: }
45: }
46:
47: public Field getField() {
48: return field;
49: }
50:
51: protected SQLIdentifier getBaseColumnNameForType(Class c) {
52: ClassBaseTable cbt;
53:
54: try {
55: cbt = storeMgr.getClassBaseTable(c);
56: } catch (ClassNotPersistenceCapableException e) {
57: cbt = null;
58: }
59:
60: if (cbt == null) {
61: String javaName = c.getName();
62: javaName = javaName
63: .substring(javaName.lastIndexOf('.') + 1);
64: return new ColumnIdentifier(dba, javaName);
65: } else
66: return cbt.getName();
67: }
68: }
|