001: //$Id: LoadEvent.java 7785 2005-08-08 23:24:44Z oneovthafew $
002: package org.hibernate.event;
003:
004: import java.io.Serializable;
005:
006: import org.hibernate.LockMode;
007:
008: /**
009: * Defines an event class for the loading of an entity.
010: *
011: * @author Steve Ebersole
012: */
013: public class LoadEvent extends AbstractEvent {
014:
015: public static final LockMode DEFAULT_LOCK_MODE = LockMode.NONE;
016:
017: private Serializable entityId;
018: private String entityClassName;
019: private Object instanceToLoad;
020: private LockMode lockMode;
021: private boolean isAssociationFetch;
022: private Object result;
023:
024: public LoadEvent(Serializable entityId, Object instanceToLoad,
025: EventSource source) {
026: this (entityId, null, instanceToLoad, null, false, source);
027: }
028:
029: public LoadEvent(Serializable entityId, String entityClassName,
030: LockMode lockMode, EventSource source) {
031: this (entityId, entityClassName, null, lockMode, false, source);
032: }
033:
034: public LoadEvent(Serializable entityId, String entityClassName,
035: boolean isAssociationFetch, EventSource source) {
036: this (entityId, entityClassName, null, null, isAssociationFetch,
037: source);
038: }
039:
040: public boolean isAssociationFetch() {
041: return isAssociationFetch;
042: }
043:
044: private LoadEvent(Serializable entityId, String entityClassName,
045: Object instanceToLoad, LockMode lockMode,
046: boolean isAssociationFetch, EventSource source) {
047:
048: super (source);
049:
050: if (entityId == null) {
051: throw new IllegalArgumentException(
052: "id to load is required for loading");
053: }
054:
055: if (lockMode == LockMode.WRITE) {
056: throw new IllegalArgumentException(
057: "Invalid lock mode for loading");
058: } else if (lockMode == null) {
059: lockMode = DEFAULT_LOCK_MODE;
060: }
061:
062: this .entityId = entityId;
063: this .entityClassName = entityClassName;
064: this .instanceToLoad = instanceToLoad;
065: this .lockMode = lockMode;
066: this .isAssociationFetch = isAssociationFetch;
067: }
068:
069: public Serializable getEntityId() {
070: return entityId;
071: }
072:
073: public void setEntityId(Serializable entityId) {
074: this .entityId = entityId;
075: }
076:
077: public String getEntityClassName() {
078: return entityClassName;
079: }
080:
081: public void setEntityClassName(String entityClassName) {
082: this .entityClassName = entityClassName;
083: }
084:
085: public Object getInstanceToLoad() {
086: return instanceToLoad;
087: }
088:
089: public void setInstanceToLoad(Object instanceToLoad) {
090: this .instanceToLoad = instanceToLoad;
091: }
092:
093: public LockMode getLockMode() {
094: return lockMode;
095: }
096:
097: public void setLockMode(LockMode lockMode) {
098: this .lockMode = lockMode;
099: }
100:
101: public Object getResult() {
102: return result;
103: }
104:
105: public void setResult(Object result) {
106: this.result = result;
107: }
108: }
|