KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > cfg > FkSecondPass


1 // $Id: FkSecondPass.java,v 1.5 2005/07/20 00:06:10 epbernard Exp $
2
package org.hibernate.cfg;
3
4 import java.util.Map JavaDoc;
5
6 import org.hibernate.AssertionFailure;
7 import org.hibernate.MappingException;
8 import org.hibernate.mapping.ManyToOne;
9 import org.hibernate.mapping.Value;
10
11 /**
12  * Enable a proper set of the FK columns in respect with the id column order
13  * Allow the correct implementation of the default EJB3 values which needs both
14  * sides of the association to be resolved
15  *
16  * @author Emmanuel Bernard
17  */

18 public class FkSecondPass extends SecondPass {
19     private Value value;
20     private Ejb3JoinColumn[] columns;
21     private boolean unique;
22
23     FkSecondPass(Value value, Ejb3JoinColumn[] columns, boolean unique, Mappings mappings) {
24         super(mappings, null);
25         this.value = value;
26         this.columns = columns;
27         this.unique = unique;
28     }
29
30     void doSecondPass(java.util.Map JavaDoc persistentClasses, java.util.Map JavaDoc inheritedMetas) throws MappingException {
31         secondPass(persistentClasses, inheritedMetas);
32     }
33
34     public void secondPass(Map JavaDoc persistentClasses, Map JavaDoc inheritedMetas) throws MappingException {
35         if (value instanceof ManyToOne) {
36             ManyToOne manyToOne = (ManyToOne) value;
37             AnnotationBinder.bindFkSecondPass(
38                     (ManyToOne) value,
39                     columns,
40                     persistentClasses,
41                     unique,
42                     (ExtendedMappings) mappings
43             );
44             manyToOne.createPropertyRefConstraints(persistentClasses);
45         }
46         else {
47             throw new AssertionFailure("FkSecondPass for a wrong value type: " + value.getClass().getName() );
48         }
49     }
50 }
51
Popular Tags