KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: LoadEvent.java,v 1.7 2005/05/27 03:53:58 oneovthafew Exp $
2
package org.hibernate.event;
3
4 import java.io.Serializable JavaDoc;
5
6 import org.hibernate.LockMode;
7
8 /**
9  * Defines an event class for the loading of an entity.
10  *
11  * @author Steve Ebersole
12  */

13 public class LoadEvent extends AbstractEvent {
14
15     public static final LockMode DEFAULT_LOCK_MODE = LockMode.NONE;
16
17     private Serializable JavaDoc entityId;
18     private String JavaDoc entityClassName;
19     private Object JavaDoc instanceToLoad;
20     private LockMode lockMode;
21     private boolean isAssociationFetch;
22
23     public LoadEvent(Serializable JavaDoc entityId, Object JavaDoc instanceToLoad, EventSource source) {
24         this(entityId, null, instanceToLoad, null, false, source);
25     }
26
27     public LoadEvent(Serializable JavaDoc entityId, String JavaDoc entityClassName, LockMode lockMode, EventSource source) {
28         this(entityId, entityClassName, null, lockMode, false, source);
29     }
30     
31     public LoadEvent(Serializable JavaDoc entityId, String JavaDoc entityClassName, boolean isAssociationFetch, EventSource source) {
32         this(entityId, entityClassName, null, null, isAssociationFetch, source);
33     }
34     
35     public boolean isAssociationFetch() {
36         return isAssociationFetch;
37     }
38
39     private LoadEvent(
40             Serializable JavaDoc entityId,
41             String JavaDoc entityClassName,
42             Object JavaDoc instanceToLoad,
43             LockMode lockMode,
44             boolean isAssociationFetch,
45             EventSource source) {
46
47         super(source);
48
49         if ( entityId == null ) {
50             throw new IllegalArgumentException JavaDoc("id to load is required for loading");
51         }
52
53         if ( lockMode == LockMode.WRITE ) {
54             throw new IllegalArgumentException JavaDoc("Invalid lock mode for loading");
55         }
56         else if ( lockMode == null ) {
57             lockMode = DEFAULT_LOCK_MODE;
58         }
59
60         this.entityId = entityId;
61         this.entityClassName = entityClassName;
62         this.instanceToLoad = instanceToLoad;
63         this.lockMode = lockMode;
64         this.isAssociationFetch = isAssociationFetch;
65     }
66
67     public Serializable JavaDoc getEntityId() {
68         return entityId;
69     }
70
71     public void setEntityId(Serializable JavaDoc entityId) {
72         this.entityId = entityId;
73     }
74
75     public String JavaDoc getEntityClassName() {
76         return entityClassName;
77     }
78
79     public void setEntityClassName(String JavaDoc entityClassName) {
80         this.entityClassName = entityClassName;
81     }
82
83     public Object JavaDoc getInstanceToLoad() {
84         return instanceToLoad;
85     }
86
87     public void setInstanceToLoad(Object JavaDoc instanceToLoad) {
88         this.instanceToLoad = instanceToLoad;
89     }
90
91     public LockMode getLockMode() {
92         return lockMode;
93     }
94
95     public void setLockMode(LockMode lockMode) {
96         this.lockMode = lockMode;
97     }
98 }
99
Popular Tags