KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > jdbc > JdbcFetchGroupBuilder


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.jdbc;
13
14 import com.versant.core.metadata.*;
15 import com.versant.core.jdbc.metadata.JdbcFetchGroup;
16 import com.versant.core.jdbc.metadata.JdbcField;
17
18 import java.util.ArrayList JavaDoc;
19
20 /**
21  * JDBC specific tweaks to how the FetchGroup's are constructed.
22  */

23 public class JdbcFetchGroupBuilder extends FetchGroupBuilder {
24
25     public JdbcFetchGroupBuilder(ModelMetaData jmd) {
26         super(jmd, false, false);
27     }
28
29     protected StoreFetchGroup createStoreFetchGroup() {
30         return new JdbcFetchGroup();
31     }
32
33     protected FetchGroupField createFetchGroupFieldWithPrefetch(
34             FieldMetaData fmd) {
35         FetchGroupField fgf = super.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, createStoreFetchGroup());
44         FieldMetaData[] fields = cmd.fields;
45         int n = fields.length;
46         ArrayList JavaDoc a = new ArrayList JavaDoc(n);
47         for (int i = 0; i < n; i++) {
48             FieldMetaData fmd = fields[i];
49             if (fmd.persistenceModifier != MDStatics.PERSISTENCE_MODIFIER_PERSISTENT) {
50                 continue;
51             }
52             if (fmd.isEmbeddedRef()) {
53                 continue;
54             }
55             JdbcField jdbcField = (JdbcField)fmd.storeField;
56             if (jdbcField.mainTableCols == null || jdbcField.mainTableCols.length == 0) {
57                 continue;
58             }
59             FetchGroupField fgf = new FetchGroupField(fmd);
60             if (fmd.category == MDStatics.CATEGORY_REF) {
61                 fgf.jdbcUseJoin = JdbcField.USE_JOIN_NO;
62             }
63             a.add(fgf);
64         }
65         n = a.size();
66         g.fields = new FetchGroupField[n];
67         a.toArray(g.fields);
68         return g;
69     }
70
71 }
72
73
Popular Tags