KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > engine > SessionImplementor


1 //$Id: SessionImplementor.java,v 1.55 2005/07/18 04:14:02 oneovthafew Exp $
2
package org.hibernate.engine;
3
4 import java.io.Serializable JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.Iterator JavaDoc;
7 import java.util.List JavaDoc;
8 import java.util.Map JavaDoc;
9
10 import org.hibernate.CacheMode;
11 import org.hibernate.EntityMode;
12 import org.hibernate.FlushMode;
13 import org.hibernate.HibernateException;
14 import org.hibernate.Interceptor;
15 import org.hibernate.Query;
16 import org.hibernate.ScrollMode;
17 import org.hibernate.ScrollableResults;
18 import org.hibernate.Transaction;
19 import org.hibernate.collection.PersistentCollection;
20 import org.hibernate.event.SessionEventListenerConfig;
21 import org.hibernate.impl.CriteriaImpl;
22 import org.hibernate.jdbc.Batcher;
23 import org.hibernate.loader.custom.CustomQuery;
24 import org.hibernate.persister.entity.EntityPersister;
25 import org.hibernate.type.Type;
26
27
28 /**
29  * Defines the internal contract between the <tt>Session</tt> and other parts of
30  * Hibernate such as implementors of <tt>Type</tt> or <tt>EntityPersister</tt>.
31  *
32  * @see org.hibernate.Session the interface to the application
33  * @see org.hibernate.impl.SessionImpl the actual implementation
34  * @author Gavin King
35  */

36 public interface SessionImplementor extends Serializable JavaDoc {
37
38     /**
39      * Retrieves the interceptor currently in use by this event source.
40      *
41      * @return The interceptor.
42      */

43     public Interceptor getInterceptor();
44     
45     /**
46      * Enable/disable automatic cache clearing from after transaction
47      * completion (for EJB3)
48      */

49     public void setAutoClear(boolean enabled);
50         
51     /**
52      * Does this <tt>Session</tt> have an active Hibernate transaction
53      * or is there a JTA transaction in progress?
54      */

55     public boolean isTransactionInProgress();
56
57     /**
58      * Initialize the collection (if not already initialized)
59      */

60     public void initializeCollection(PersistentCollection collection, boolean writing)
61     throws HibernateException;
62     
63     /**
64      * Load an instance without checking if it was deleted.
65      *
66      * When <tt>nullable</tt> is disabled this method may create a new proxy or
67      * return an existing proxy; if it does not exist, throw an exception.
68      *
69      * When <tt>nullable</tt> is enabled, the method does not create new proxies
70      * (but might return an existing proxy); if it does not exist, return
71      * <tt>null</tt>.
72      *
73      * When <tt>eager</tt> is enabled, the object is eagerly fetched
74      */

75     public Object JavaDoc internalLoad(String JavaDoc entityName, Serializable JavaDoc id, boolean eager, boolean nullable)
76     throws HibernateException;
77
78     /**
79      * Load an instance immediately. This method is only called when lazily initializing a proxy.
80      * Do not return the proxy.
81      */

82     public Object JavaDoc immediateLoad(String JavaDoc entityName, Serializable JavaDoc id) throws HibernateException;
83
84     /**
85      * System time before the start of the transaction
86      */

87     public long getTimestamp();
88     /**
89      * Get the creating <tt>SessionFactoryImplementor</tt>
90      */

91     public SessionFactoryImplementor getFactory();
92     /**
93      * Get the prepared statement <tt>Batcher</tt> for this session
94      */

95     public Batcher getBatcher();
96     
97     /**
98      * Execute a <tt>find()</tt> query
99      */

100     public List JavaDoc list(String JavaDoc query, QueryParameters queryParameters) throws HibernateException;
101     /**
102      * Execute an <tt>iterate()</tt> query
103      */

104     public Iterator JavaDoc iterate(String JavaDoc query, QueryParameters queryParameters) throws HibernateException;
105     /**
106      * Execute a <tt>scroll()</tt> query
107      */

108     public ScrollableResults scroll(String JavaDoc query, QueryParameters queryParameters) throws HibernateException;
109     /**
110      * Execute a criteria query
111      */

112     public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode);
113     /**
114      * Execute a criteria query
115      */

116     public List JavaDoc list(CriteriaImpl criteria);
117     
118     /**
119      * Execute a filter
120      */

121     public List JavaDoc listFilter(Object JavaDoc collection, String JavaDoc filter, QueryParameters queryParameters) throws HibernateException;
122     /**
123      * Iterate a filter
124      */

125     public Iterator JavaDoc iterateFilter(Object JavaDoc collection, String JavaDoc filter, QueryParameters queryParameters) throws HibernateException;
126     
127     /**
128      * Get the <tt>EntityPersister</tt> for any instance
129      * @param entityName optional entity name
130      * @param object the entity instance
131      */

132     public EntityPersister getEntityPersister(String JavaDoc entityName, Object JavaDoc object) throws HibernateException;
133     
134     /**
135      * Get the entity instance associated with the given <tt>Key</tt>,
136      * calling the Interceptor if necessary
137      */

138     public Object JavaDoc getEntityUsingInterceptor(EntityKey key) throws HibernateException;
139
140     /**
141      * Notify the session that the transaction completed, so we no longer
142      * own the old locks. (Also we should release cache softlocks.) May
143      * be called multiple times during the transaction completion process.
144      * Also called after an autocommit, in which case the second argument
145      * is null.
146      */

147     public void afterTransactionCompletion(boolean successful, Transaction tx);
148     
149     /**
150      * Notify the session that the transaction is about to complete
151      */

152     public void beforeTransactionCompletion(Transaction tx);
153
154     /**
155      * Return the identifier of the persistent object, or null if
156      * not associated with the session
157      */

158     public Serializable JavaDoc getContextEntityIdentifier(Object JavaDoc object);
159
160     /**
161      * The best guess entity name for an entity not in an association
162      */

163     public String JavaDoc bestGuessEntityName(Object JavaDoc object);
164     
165     /**
166      * The guessed entity name for an entity not in an association
167      */

168     public String JavaDoc guessEntityName(Object JavaDoc entity) throws HibernateException;
169     
170     /**
171      * Instantiate the entity class, initializing with the given identifier
172      */

173     public Object JavaDoc instantiate(String JavaDoc entityName, Serializable JavaDoc id) throws HibernateException;
174     
175     /**
176      * Execute an SQL Query
177      */

178     public List JavaDoc listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
179     throws HibernateException;
180     
181     /**
182      * Execute an SQL Query
183      */

184     public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
185     throws HibernateException;
186
187     /**
188      * Retreive the currently set value for a filter parameter.
189      *
190      * @param filterParameterName The filter parameter name in the format
191      * {FILTER_NAME.PARAMETER_NAME}.
192      * @return The filter parameter value.
193      */

194     public Object JavaDoc getFilterParameterValue(String JavaDoc filterParameterName);
195
196     /**
197      * Retreive the type for a given filter parrameter.
198      *
199      * @param filterParameterName The filter parameter name in the format
200      * {FILTER_NAME.PARAMETER_NAME}.
201      * @return
202      */

203     public Type getFilterParameterType(String JavaDoc filterParameterName);
204
205     /**
206      * Return the currently enabled filters. The filter map is keyed by filter
207      * name, with values corresponding to the {@link org.hibernate.impl.FilterImpl}
208      * instance.
209      * @return The currently enabled filters.
210      */

211     public Map JavaDoc getEnabledFilters();
212     
213     public int getDontFlushFromFind();
214     
215     /**
216      * Retrieves the configured event listeners from this event source.
217      *
218      * @return The configured event listeners.
219      */

220     public SessionEventListenerConfig getListeners();
221     
222     //TODO: temporary
223

224     /**
225      * Get the persistence context for this session
226      */

227     public PersistenceContext getPersistenceContext();
228     
229     /**
230      * Execute a HQL update or delete query
231      */

232     int executeUpdate(String JavaDoc query, QueryParameters queryParameters) throws HibernateException;
233     
234     // copied from Session:
235

236     public EntityMode getEntityMode();
237     public CacheMode getCacheMode();
238     public void setCacheMode(CacheMode cm);
239     public boolean isOpen();
240     public boolean isConnected();
241     public FlushMode getFlushMode();
242     public void setFlushMode(FlushMode fm);
243     public Connection JavaDoc connection();
244     
245     /**
246      * Get a Query instance for a named query or named native SQL query
247      */

248     public Query getNamedQuery(String JavaDoc name);
249     /**
250      * Get a Query instance for a named native SQL query
251      */

252     public Query getNamedSQLQuery(String JavaDoc name);
253     
254     public boolean isEventSource();
255
256     public void afterScrollOperation();
257 }
258
Popular Tags