KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > event > LoadEventListener


1 //$Id: LoadEventListener.java,v 1.4 2005/04/28 08:35:08 oneovthafew Exp $
2
package org.hibernate.event;
3
4 import org.hibernate.HibernateException;
5
6 import java.io.Serializable JavaDoc;
7
8 /**
9  * Defines the contract for handling of load events generated from a session.
10  *
11  * @author Steve Ebersole
12  */

13 public interface LoadEventListener extends Serializable JavaDoc {
14
15     /**
16      * Handle the given load event.
17      *
18      * @param event The load event to be handled.
19      * @return The result (i.e., the loaded entity).
20      * @throws HibernateException
21      */

22     public Object JavaDoc onLoad(LoadEvent event, LoadType loadType) throws HibernateException;
23
24     public static final LoadType RELOAD = new LoadType("GET")
25             .setAllowNulls(false)
26             .setAllowProxyCreation(false)
27             .setCheckDeleted(true)
28             .setNakedEntityReturned(false);
29
30     public static final LoadType GET = new LoadType("GET")
31             .setAllowNulls(true)
32             .setAllowProxyCreation(false)
33             .setCheckDeleted(true)
34             .setNakedEntityReturned(false);
35     
36     public static final LoadType LOAD = new LoadType("LOAD")
37             .setAllowNulls(false)
38             .setAllowProxyCreation(true)
39             .setCheckDeleted(true)
40             .setNakedEntityReturned(false);
41     
42     public static final LoadType IMMEDIATE_LOAD = new LoadType("IMMEDIATE_LOAD")
43             .setAllowNulls(false)
44             .setAllowProxyCreation(false)
45             .setCheckDeleted(false)
46             .setNakedEntityReturned(true);
47     
48     public static final LoadType INTERNAL_LOAD_EAGER = new LoadType("INTERNAL_LOAD_EAGER")
49             .setAllowNulls(false)
50             .setAllowProxyCreation(false)
51             .setCheckDeleted(false)
52             .setNakedEntityReturned(false);
53     
54     public static final LoadType INTERNAL_LOAD_LAZY = new LoadType("INTERNAL_LOAD_LAZY")
55             .setAllowNulls(false)
56             .setAllowProxyCreation(true)
57             .setCheckDeleted(false)
58             .setNakedEntityReturned(false);
59     
60     public static final LoadType INTERNAL_LOAD_NULLABLE = new LoadType("INTERNAL_LOAD_NULLABLE")
61             .setAllowNulls(true)
62             .setAllowProxyCreation(false)
63             .setCheckDeleted(false)
64             .setNakedEntityReturned(false);
65
66     public static final class LoadType {
67         private String JavaDoc name;
68
69         private boolean nakedEntityReturned;
70         private boolean allowNulls;
71         private boolean checkDeleted;
72         private boolean allowProxyCreation;
73
74         private LoadType(String JavaDoc name) {
75             this.name = name;
76         }
77
78         public boolean isAllowNulls() {
79             return allowNulls;
80         }
81
82         private LoadType setAllowNulls(boolean allowNulls) {
83             this.allowNulls = allowNulls;
84             return this;
85         }
86
87         public boolean isNakedEntityReturned() {
88             return nakedEntityReturned;
89         }
90
91         private LoadType setNakedEntityReturned(boolean immediateLoad) {
92             this.nakedEntityReturned = immediateLoad;
93             return this;
94         }
95
96         public boolean isCheckDeleted() {
97             return checkDeleted;
98         }
99
100         private LoadType setCheckDeleted(boolean checkDeleted) {
101             this.checkDeleted = checkDeleted;
102             return this;
103         }
104
105         public boolean isAllowProxyCreation() {
106             return allowProxyCreation;
107         }
108
109         private LoadType setAllowProxyCreation(boolean allowProxyCreation) {
110             this.allowProxyCreation = allowProxyCreation;
111             return this;
112         }
113
114         public String JavaDoc getName() {
115             return name;
116         }
117         
118         public String JavaDoc toString() {
119             return name;
120         }
121     }
122 }
123
Popular Tags