01: //$Id: LazyInitializer.java 7246 2005-06-20 20:32:36Z oneovthafew $
02: package org.hibernate.proxy;
03:
04: import java.io.Serializable;
05:
06: import org.hibernate.HibernateException;
07: import org.hibernate.engine.SessionImplementor;
08:
09: /**
10: * Handles fetching of the underlying entity for a proxy
11: * @author Gavin King
12: */
13: public interface LazyInitializer {
14:
15: /**
16: * Initialize the proxy, fetching the target
17: * entity if necessary
18: */
19: public abstract void initialize() throws HibernateException;
20:
21: /**
22: * Get the identifier held by the proxy
23: */
24: public abstract Serializable getIdentifier();
25:
26: /**
27: * Set the identifier property of the proxy
28: */
29: public abstract void setIdentifier(Serializable id);
30:
31: /**
32: * Get the entity name
33: */
34: public abstract String getEntityName();
35:
36: /**
37: * Get the actual class of the entity (don't
38: * use this, use the entityName)
39: */
40: public abstract Class getPersistentClass();
41:
42: /**
43: * Is the proxy uninitialzed?
44: */
45: public abstract boolean isUninitialized();
46:
47: /**
48: * Initialize the proxy manually
49: */
50: public abstract void setImplementation(Object target);
51:
52: /**
53: * Get the session, if this proxy is attached
54: */
55: public abstract SessionImplementor getSession();
56:
57: /**
58: * Attach the proxy to a session
59: */
60: public abstract void setSession(SessionImplementor s)
61: throws HibernateException;
62:
63: /**
64: * Return the underlying persistent object, initializing if necessary
65: */
66: public abstract Object getImplementation();
67:
68: /**
69: * Return the underlying persistent object in the given <tt>Session</tt>, or null
70: */
71: public abstract Object getImplementation(SessionImplementor s)
72: throws HibernateException;
73:
74: public void setUnwrap(boolean unwrap);
75:
76: public boolean isUnwrap();
77: }
|