01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.jdbc;
12:
13: import com.versant.core.metadata.*;
14: import com.versant.core.jdbc.metadata.JdbcFetchGroup;
15: import com.versant.core.jdbc.metadata.JdbcField;
16:
17: import java.util.ArrayList;
18:
19: /**
20: * JDBC specific tweaks to how the FetchGroup's are constructed.
21: */
22: public class JdbcFetchGroupBuilder extends FetchGroupBuilder {
23:
24: public JdbcFetchGroupBuilder(ModelMetaData jmd) {
25: super (jmd, false, false);
26: }
27:
28: protected StoreFetchGroup createStoreFetchGroup() {
29: return new JdbcFetchGroup();
30: }
31:
32: protected FetchGroupField createFetchGroupFieldWithPrefetch(
33: FieldMetaData fmd) {
34: FetchGroupField fgf = super
35: .createFetchGroupFieldWithPrefetch(fmd);
36: if (fmd.category == MDStatics.CATEGORY_REF) {
37: fgf.jdbcUseJoin = JdbcField.USE_JOIN_OUTER;
38: }
39: return fgf;
40: }
41:
42: protected FetchGroup createAllColumnsFetchGroup(ClassMetaData cmd) {
43: FetchGroup g = new FetchGroup(cmd, FetchGroup.ALL_COLS_NAME,
44: createStoreFetchGroup());
45: FieldMetaData[] fields = cmd.fields;
46: int n = fields.length;
47: ArrayList a = new ArrayList(n);
48: for (int i = 0; i < n; i++) {
49: FieldMetaData fmd = fields[i];
50: if (fmd.persistenceModifier != MDStatics.PERSISTENCE_MODIFIER_PERSISTENT) {
51: continue;
52: }
53: if (fmd.isEmbeddedRef()) {
54: continue;
55: }
56: JdbcField jdbcField = (JdbcField) fmd.storeField;
57: if (jdbcField.mainTableCols == null
58: || jdbcField.mainTableCols.length == 0) {
59: continue;
60: }
61: FetchGroupField fgf = new FetchGroupField(fmd);
62: if (fmd.category == MDStatics.CATEGORY_REF) {
63: fgf.jdbcUseJoin = JdbcField.USE_JOIN_NO;
64: }
65: a.add(fgf);
66: }
67: n = a.size();
68: g.fields = new FetchGroupField[n];
69: a.toArray(g.fields);
70: return g;
71: }
72:
73: }
|