View Javadoc

1   package net.sourceforge.blogentis.om.map;
2   
3   import org.apache.torque.Torque;
4   import org.apache.torque.TorqueException;
5   import org.apache.torque.map.DatabaseMap;
6   import org.apache.torque.map.MapBuilder;
7   import org.apache.torque.map.TableMap;
8   
9   /***
10    */
11  public class PostSectionMapBuilder implements MapBuilder
12  {
13      /***
14       * The name of this class
15       */
16      public static final String CLASS_NAME =
17          "net.sourceforge.blogentis.om.map.PostSectionMapBuilder";
18  
19  
20      /***
21       * The database map.
22       */
23      private DatabaseMap dbMap = null;
24  
25      /***
26       * Tells us if this DatabaseMapBuilder is built so that we
27       * don't have to re-build it every time.
28       *
29       * @return true if this DatabaseMapBuilder is built
30       */
31      public boolean isBuilt()
32      {
33          return (dbMap != null);
34      }
35  
36      /***
37       * Gets the databasemap this map builder built.
38       *
39       * @return the databasemap
40       */
41      public DatabaseMap getDatabaseMap()
42      {
43          return this.dbMap;
44      }
45  
46      /***
47       * The doBuild() method builds the DatabaseMap
48       *
49       * @throws TorqueException
50       */
51      public void doBuild() throws TorqueException
52      {
53          dbMap = Torque.getDatabaseMap("blogentis");
54  
55          dbMap.addTable("Post_Section");
56          TableMap tMap = dbMap.getTable("Post_Section");
57  
58          tMap.setPrimaryKeyMethod("none");
59  
60  
61                tMap.addForeignPrimaryKey(
62                  "Post_Section.POST_ID", new Integer(0) , "Post" ,
63                  "Post_Id");
64                      tMap.addForeignPrimaryKey(
65                  "Post_Section.SECTION_ID", new Integer(0) , "Section" ,
66                  "Section_Id");
67            }
68  }