KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > mapping > DenormalizedTable


1 //$Id: DenormalizedTable.java,v 1.3 2004/08/22 15:43:15 oneovthafew Exp $
2
package org.hibernate.mapping;
3
4 import java.util.Iterator JavaDoc;
5
6 import org.hibernate.util.JoinedIterator;
7
8 /**
9  * @author Gavin King
10  */

11 public class DenormalizedTable extends Table {
12     
13     private final Table includedTable;
14     
15     public DenormalizedTable(Table includedTable) {
16         this.includedTable = includedTable;
17         includedTable.setHasDenormalizedTables();
18     }
19     
20     public void createForeignKeys() {
21         includedTable.createForeignKeys();
22         Iterator JavaDoc iter = includedTable.getForeignKeyIterator();
23         while ( iter.hasNext() ) {
24             ForeignKey fk = (ForeignKey) iter.next();
25             this.createForeignKey(
26                     fk.getName() + Integer.toHexString( getName().hashCode() ),
27                     fk.getColumns(),
28                     fk.getReferencedEntityName()
29             );
30         }
31     }
32
33
34     public Iterator JavaDoc getColumnIterator() {
35         return new JoinedIterator(
36             includedTable.getColumnIterator(),
37             super.getColumnIterator()
38         );
39     }
40
41
42     public boolean containsColumn(Column column) {
43         return super.containsColumn(column) || includedTable.containsColumn(column);
44     }
45
46     public PrimaryKey getPrimaryKey() {
47         return includedTable.getPrimaryKey();
48     }
49 }
50
Popular Tags