1 package org.hibernate.event; 3 4 import java.io.Serializable ; 5 6 import org.hibernate.LockMode; 7 8 13 public class LoadEvent extends AbstractEvent { 14 15 public static final LockMode DEFAULT_LOCK_MODE = LockMode.NONE; 16 17 private Serializable entityId; 18 private String entityClassName; 19 private Object instanceToLoad; 20 private LockMode lockMode; 21 private boolean isAssociationFetch; 22 23 public LoadEvent(Serializable entityId, Object instanceToLoad, EventSource source) { 24 this(entityId, null, instanceToLoad, null, false, source); 25 } 26 27 public LoadEvent(Serializable entityId, String entityClassName, LockMode lockMode, EventSource source) { 28 this(entityId, entityClassName, null, lockMode, false, source); 29 } 30 31 public LoadEvent(Serializable entityId, String 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 entityId, 41 String entityClassName, 42 Object instanceToLoad, 43 LockMode lockMode, 44 boolean isAssociationFetch, 45 EventSource source) { 46 47 super(source); 48 49 if ( entityId == null ) { 50 throw new IllegalArgumentException ("id to load is required for loading"); 51 } 52 53 if ( lockMode == LockMode.WRITE ) { 54 throw new IllegalArgumentException ("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 getEntityId() { 68 return entityId; 69 } 70 71 public void setEntityId(Serializable entityId) { 72 this.entityId = entityId; 73 } 74 75 public String getEntityClassName() { 76 return entityClassName; 77 } 78 79 public void setEntityClassName(String entityClassName) { 80 this.entityClassName = entityClassName; 81 } 82 83 public Object getInstanceToLoad() { 84 return instanceToLoad; 85 } 86 87 public void setInstanceToLoad(Object 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 |