KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > type > ForeignKeyDirection


1 //$Id: ForeignKeyDirection.java,v 1.4 2005/06/05 05:09:58 oneovthafew Exp $
2
package org.hibernate.type;
3
4 import java.io.Serializable JavaDoc;
5
6 import org.hibernate.engine.Cascade;
7
8 /**
9  * Represents directionality of the foreign key constraint
10  * @author Gavin King
11  */

12 public abstract class ForeignKeyDirection implements Serializable JavaDoc {
13     protected ForeignKeyDirection() {}
14     /**
15      * Should we cascade at this cascade point?
16      * @see org.hibernate.engine.Cascade
17      */

18     public abstract boolean cascadeNow(int cascadePoint);
19
20     /**
21      * A foreign key from child to parent
22      */

23     public static final ForeignKeyDirection FOREIGN_KEY_TO_PARENT = new ForeignKeyDirection() {
24         public boolean cascadeNow(int cascadePoint) {
25             return cascadePoint!=Cascade.BEFORE_INSERT_AFTER_DELETE;
26         }
27
28         public String JavaDoc toString() {
29             return "toParent";
30         }
31         
32         Object JavaDoc readResolve() {
33             return FOREIGN_KEY_TO_PARENT;
34         }
35     };
36     /**
37      * A foreign key from parent to child
38      */

39     public static final ForeignKeyDirection FOREIGN_KEY_FROM_PARENT = new ForeignKeyDirection() {
40         public boolean cascadeNow(int cascadePoint) {
41             return cascadePoint!=Cascade.AFTER_INSERT_BEFORE_DELETE;
42         }
43
44         public String JavaDoc toString() {
45             return "fromParent";
46         }
47         
48         Object JavaDoc readResolve() {
49             return FOREIGN_KEY_FROM_PARENT;
50         }
51     };
52 }
Popular Tags