Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
33 | PointedEar | 1 | /* |
2 | * Hibernate, Relational Persistence for Idiomatic Java |
||
3 | * |
||
4 | * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as |
||
5 | * indicated by the @author tags or express copyright attribution |
||
6 | * statements applied by the authors. All third-party contributions are |
||
7 | * distributed under license by Red Hat Middleware LLC. |
||
8 | * |
||
9 | * This copyrighted material is made available to anyone wishing to use, modify, |
||
10 | * copy, or redistribute it subject to the terms and conditions of the GNU |
||
11 | * Lesser General Public License, as published by the Free Software Foundation. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
||
16 | * for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Lesser General Public License |
||
19 | * along with this distribution; if not, write to: |
||
20 | * Free Software Foundation, Inc. |
||
21 | * 51 Franklin Street, Fifth Floor |
||
22 | * Boston, MA 02110-1301 USA |
||
23 | * |
||
24 | */ |
||
25 | package org.hibernate; |
||
26 | |||
27 | import java.io.Serializable; |
||
28 | import java.sql.Connection; |
||
29 | import java.util.Map; |
||
30 | import java.util.Set; |
||
31 | |||
32 | import javax.naming.Referenceable; |
||
33 | |||
34 | import org.hibernate.metadata.ClassMetadata; |
||
35 | import org.hibernate.metadata.CollectionMetadata; |
||
36 | import org.hibernate.stat.Statistics; |
||
37 | import org.hibernate.engine.FilterDefinition; |
||
38 | |||
39 | /** |
||
40 | * Creates <tt>Session</tt>s. Usually an application has a single <tt>SessionFactory</tt>. |
||
41 | * Threads servicing client requests obtain <tt>Session</tt>s from the factory.<br> |
||
42 | * <br> |
||
43 | * Implementors must be threadsafe.<br> |
||
44 | * <br> |
||
45 | * <tt>SessionFactory</tt>s are immutable. The behaviour of a <tt>SessionFactory</tt> is |
||
46 | * controlled by properties supplied at configuration time. These properties are defined |
||
47 | * on <tt>Environment</tt>. |
||
48 | * |
||
49 | * @see Session |
||
50 | * @see org.hibernate.cfg.Environment |
||
51 | * @see org.hibernate.cfg.Configuration |
||
52 | * @see org.hibernate.connection.ConnectionProvider |
||
53 | * @see org.hibernate.transaction.TransactionFactory |
||
54 | * @author Gavin King |
||
55 | */ |
||
56 | public interface SessionFactory extends Referenceable, Serializable { |
||
57 | |||
58 | /** |
||
59 | * Open a <tt>Session</tt> on the given connection. |
||
60 | * <p> |
||
61 | * Note that the second-level cache will be disabled if you |
||
62 | * supply a JDBC connection. Hibernate will not be able to track |
||
63 | * any statements you might have executed in the same transaction. |
||
64 | * Consider implementing your own <tt>ConnectionProvider</tt>. |
||
65 | * |
||
66 | * @param connection a connection provided by the application. |
||
67 | * @return Session |
||
68 | */ |
||
69 | public org.hibernate.classic.Session openSession(Connection connection); |
||
70 | |||
71 | /** |
||
72 | * Create database connection and open a <tt>Session</tt> on it, specifying an |
||
73 | * interceptor. |
||
74 | * |
||
75 | * @param interceptor a session-scoped interceptor |
||
76 | * @return Session |
||
77 | * @throws HibernateException |
||
78 | */ |
||
79 | public org.hibernate.classic.Session openSession(Interceptor interceptor) throws HibernateException; |
||
80 | |||
81 | /** |
||
82 | * Open a <tt>Session</tt> on the given connection, specifying an interceptor. |
||
83 | * <p> |
||
84 | * Note that the second-level cache will be disabled if you |
||
85 | * supply a JDBC connection. Hibernate will not be able to track |
||
86 | * any statements you might have executed in the same transaction. |
||
87 | * Consider implementing your own <tt>ConnectionProvider</tt>. |
||
88 | * |
||
89 | * @param connection a connection provided by the application. |
||
90 | * @param interceptor a session-scoped interceptor |
||
91 | * @return Session |
||
92 | */ |
||
93 | public org.hibernate.classic.Session openSession(Connection connection, Interceptor interceptor); |
||
94 | |||
95 | /** |
||
96 | * Create database connection and open a <tt>Session</tt> on it. |
||
97 | * |
||
98 | * @return Session |
||
99 | * @throws HibernateException |
||
100 | */ |
||
101 | public org.hibernate.classic.Session openSession() throws HibernateException; |
||
102 | |||
103 | /** |
||
104 | * Obtains the current session. The definition of what exactly "current" |
||
105 | * means controlled by the {@link org.hibernate.context.CurrentSessionContext} impl configured |
||
106 | * for use. |
||
107 | * <p/> |
||
108 | * Note that for backwards compatibility, if a {@link org.hibernate.context.CurrentSessionContext} |
||
109 | * is not configured but a JTA {@link org.hibernate.transaction.TransactionManagerLookup} |
||
110 | * is configured this will default to the {@link org.hibernate.context.JTASessionContext} |
||
111 | * impl. |
||
112 | * |
||
113 | * @return The current session. |
||
114 | * @throws HibernateException Indicates an issue locating a suitable current session. |
||
115 | */ |
||
116 | public org.hibernate.classic.Session getCurrentSession() throws HibernateException; |
||
117 | |||
118 | /** |
||
119 | * Get the <tt>ClassMetadata</tt> associated with the given entity class |
||
120 | * |
||
121 | * @see org.hibernate.metadata.ClassMetadata |
||
122 | */ |
||
123 | public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException; |
||
124 | |||
125 | /** |
||
126 | * Get the <tt>ClassMetadata</tt> associated with the given entity name |
||
127 | * |
||
128 | * @see org.hibernate.metadata.ClassMetadata |
||
129 | * @since 3.0 |
||
130 | */ |
||
131 | public ClassMetadata getClassMetadata(String entityName) throws HibernateException; |
||
132 | |||
133 | /** |
||
134 | * Get the <tt>CollectionMetadata</tt> associated with the named collection role |
||
135 | * |
||
136 | * @see org.hibernate.metadata.CollectionMetadata |
||
137 | */ |
||
138 | public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException; |
||
139 | |||
140 | |||
141 | /** |
||
142 | * Get all <tt>ClassMetadata</tt> as a <tt>Map</tt> from entityname <tt>String</tt> |
||
143 | * to metadata object |
||
144 | * |
||
145 | * @see org.hibernate.metadata.ClassMetadata |
||
146 | * @return a map from <tt>String</tt> an entity name to <tt>ClassMetaData</tt> |
||
147 | * @since 3.0 changed key from <tt>Class</tt> to <tt>String</tt> |
||
148 | */ |
||
149 | public Map getAllClassMetadata() throws HibernateException; |
||
150 | |||
151 | /** |
||
152 | * Get all <tt>CollectionMetadata</tt> as a <tt>Map</tt> from role name |
||
153 | * to metadata object |
||
154 | * |
||
155 | * @see org.hibernate.metadata.CollectionMetadata |
||
156 | * @return a map from <tt>String</tt> to <tt>CollectionMetadata</tt> |
||
157 | */ |
||
158 | public Map getAllCollectionMetadata() throws HibernateException; |
||
159 | |||
160 | /** |
||
161 | * Get the statistics for this session factory |
||
162 | */ |
||
163 | public Statistics getStatistics(); |
||
164 | |||
165 | /** |
||
166 | * Destroy this <tt>SessionFactory</tt> and release all resources (caches, |
||
167 | * connection pools, etc). It is the responsibility of the application |
||
168 | * to ensure that there are no open <tt>Session</tt>s before calling |
||
169 | * <tt>close()</tt>. |
||
170 | */ |
||
171 | public void close() throws HibernateException; |
||
172 | |||
173 | /** |
||
174 | * Was this <tt>SessionFactory</tt> already closed? |
||
175 | */ |
||
176 | public boolean isClosed(); |
||
177 | |||
178 | /** |
||
179 | * Evict all entries from the second-level cache. This method occurs outside |
||
180 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
181 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
182 | */ |
||
183 | public void evict(Class persistentClass) throws HibernateException; |
||
184 | /** |
||
185 | * Evict an entry from the second-level cache. This method occurs outside |
||
186 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
187 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
188 | */ |
||
189 | public void evict(Class persistentClass, Serializable id) throws HibernateException; |
||
190 | /** |
||
191 | * Evict all entries from the second-level cache. This method occurs outside |
||
192 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
193 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
194 | */ |
||
195 | public void evictEntity(String entityName) throws HibernateException; |
||
196 | /** |
||
197 | * Evict an entry from the second-level cache. This method occurs outside |
||
198 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
199 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
200 | */ |
||
201 | public void evictEntity(String entityName, Serializable id) throws HibernateException; |
||
202 | /** |
||
203 | * Evict all entries from the second-level cache. This method occurs outside |
||
204 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
205 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
206 | */ |
||
207 | public void evictCollection(String roleName) throws HibernateException; |
||
208 | /** |
||
209 | * Evict an entry from the second-level cache. This method occurs outside |
||
210 | * of any transaction; it performs an immediate "hard" remove, so does not respect |
||
211 | * any transaction isolation semantics of the usage strategy. Use with care. |
||
212 | */ |
||
213 | public void evictCollection(String roleName, Serializable id) throws HibernateException; |
||
214 | |||
215 | /** |
||
216 | * Evict any query result sets cached in the default query cache region. |
||
217 | */ |
||
218 | public void evictQueries() throws HibernateException; |
||
219 | /** |
||
220 | * Evict any query result sets cached in the named query cache region. |
||
221 | */ |
||
222 | public void evictQueries(String cacheRegion) throws HibernateException; |
||
223 | /** |
||
224 | * Get a new stateless session. |
||
225 | */ |
||
226 | public StatelessSession openStatelessSession(); |
||
227 | /** |
||
228 | * Get a new stateless session for the given JDBC connection. |
||
229 | */ |
||
230 | public StatelessSession openStatelessSession(Connection connection); |
||
231 | |||
232 | /** |
||
233 | * Obtain a set of the names of all filters defined on this SessionFactory. |
||
234 | * |
||
235 | * @return The set of filter names. |
||
236 | */ |
||
237 | public Set getDefinedFilterNames(); |
||
238 | |||
239 | /** |
||
240 | * Obtain the definition of a filter by name. |
||
241 | * |
||
242 | * @param filterName The name of the filter for which to obtain the definition. |
||
243 | * @return The filter definition. |
||
244 | * @throws HibernateException If no filter defined with the given name. |
||
245 | */ |
||
246 | public FilterDefinition getFilterDefinition(String filterName) throws HibernateException; |
||
247 | } |