001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.util.dao.hibernate;
022:
023: import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
024:
025: import java.io.Serializable;
026:
027: import java.lang.Class;
028: import java.lang.Object;
029: import java.lang.String;
030:
031: import java.sql.Connection;
032:
033: import org.hibernate.CacheMode;
034: import org.hibernate.Criteria;
035: import org.hibernate.EntityMode;
036: import org.hibernate.Filter;
037: import org.hibernate.FlushMode;
038: import org.hibernate.HibernateException;
039: import org.hibernate.LockMode;
040: import org.hibernate.Query;
041: import org.hibernate.ReplicationMode;
042: import org.hibernate.SQLQuery;
043: import org.hibernate.Session;
044: import org.hibernate.SessionFactory;
045: import org.hibernate.Transaction;
046: import org.hibernate.stat.SessionStatistics;
047:
048: /**
049: * <a href="LiferaySession.java.html"><b><i>View Source</i></b></a>
050: *
051: * <p>
052: * See http://support.liferay.com/browse/LEP-2996.
053: * </p>
054: *
055: * @author Brian Wing Shun Chan
056: *
057: */
058: public class LiferaySession implements Session {
059:
060: public LiferaySession(Session session) {
061: _session = session;
062: }
063:
064: public Session getHibernateSession() {
065: return _session;
066: }
067:
068: public Transaction beginTransaction() throws HibernateException {
069: return _session.beginTransaction();
070: }
071:
072: public void cancelQuery() throws HibernateException {
073: _session.cancelQuery();
074: }
075:
076: public void clear() {
077: _session.clear();
078: }
079:
080: public Connection close() throws HibernateException {
081: return _session.close();
082: }
083:
084: /**
085: * @deprecated
086: */
087: public Connection connection() throws HibernateException {
088: ClassLoader contextClassLoader = Thread.currentThread()
089: .getContextClassLoader();
090:
091: try {
092: ClassLoader portalClassLoader = PortalClassLoaderUtil
093: .getClassLoader();
094:
095: Thread.currentThread().setContextClassLoader(
096: portalClassLoader);
097:
098: Connection connection = _session.connection();
099:
100: return connection;
101: } finally {
102: Thread.currentThread().setContextClassLoader(
103: contextClassLoader);
104: }
105: }
106:
107: public boolean contains(Object object) {
108: return _session.contains(object);
109: }
110:
111: public Criteria createCriteria(Class persistentClass) {
112: return _session.createCriteria(persistentClass);
113: }
114:
115: public Criteria createCriteria(Class persistentClass, String alias) {
116: return _session.createCriteria(persistentClass, alias);
117: }
118:
119: public Criteria createCriteria(String entityName) {
120: return _session.createCriteria(entityName);
121: }
122:
123: public Criteria createCriteria(String entityName, String alias) {
124: return _session.createCriteria(entityName, alias);
125: }
126:
127: public Query createFilter(Object collection, String queryString)
128: throws HibernateException {
129:
130: return _session.createFilter(collection, queryString);
131: }
132:
133: public Query createQuery(String queryString)
134: throws HibernateException {
135: return _session.createQuery(queryString);
136: }
137:
138: public SQLQuery createSQLQuery(String queryString)
139: throws HibernateException {
140:
141: return _session.createSQLQuery(queryString);
142: }
143:
144: public void delete(Object object) throws HibernateException {
145: _session.delete(object);
146: }
147:
148: public void delete(String entityName, Object object)
149: throws HibernateException {
150:
151: _session.delete(entityName, object);
152: }
153:
154: public void disableFilter(String filterName) {
155: _session.disableFilter(filterName);
156: }
157:
158: public Connection disconnect() throws HibernateException {
159: return _session.disconnect();
160: }
161:
162: public Filter enableFilter(String filterName) {
163: return _session.enableFilter(filterName);
164: }
165:
166: public void evict(Object object) throws HibernateException {
167: _session.evict(object);
168: }
169:
170: public void flush() throws HibernateException {
171: _session.flush();
172: }
173:
174: public Object get(Class clazz, Serializable id)
175: throws HibernateException {
176: return _session.get(clazz, id);
177: }
178:
179: public Object get(Class clazz, Serializable id, LockMode lockMode)
180: throws HibernateException {
181:
182: return _session.get(clazz, id, lockMode);
183: }
184:
185: public Object get(String entityName, Serializable id)
186: throws HibernateException {
187:
188: return _session.get(entityName, id);
189: }
190:
191: public Object get(String entityName, Serializable id,
192: LockMode lockMode) throws HibernateException {
193:
194: return _session.get(entityName, id, lockMode);
195: }
196:
197: public CacheMode getCacheMode() {
198: return _session.getCacheMode();
199: }
200:
201: public LockMode getCurrentLockMode(Object object)
202: throws HibernateException {
203:
204: return _session.getCurrentLockMode(object);
205: }
206:
207: public Filter getEnabledFilter(String filterName) {
208: return _session.getEnabledFilter(filterName);
209: }
210:
211: public EntityMode getEntityMode() {
212: return _session.getEntityMode();
213: }
214:
215: public String getEntityName(Object object)
216: throws HibernateException {
217: return _session.getEntityName(object);
218: }
219:
220: public FlushMode getFlushMode() {
221: return _session.getFlushMode();
222: }
223:
224: public Serializable getIdentifier(Object object)
225: throws HibernateException {
226: return _session.getIdentifier(object);
227: }
228:
229: public Query getNamedQuery(String queryName)
230: throws HibernateException {
231: return _session.getNamedQuery(queryName);
232: }
233:
234: public Session getSession(EntityMode entityMode) {
235: return _session.getSession(entityMode);
236: }
237:
238: public SessionFactory getSessionFactory() {
239: return _session.getSessionFactory();
240: }
241:
242: public SessionStatistics getStatistics() {
243: return _session.getStatistics();
244: }
245:
246: public Transaction getTransaction() {
247: return _session.getTransaction();
248: }
249:
250: public boolean isConnected() {
251: return _session.isConnected();
252: }
253:
254: public boolean isDirty() throws HibernateException {
255: return _session.isDirty();
256: }
257:
258: public boolean isOpen() {
259: return _session.isOpen();
260: }
261:
262: public Object load(Class theClass, Serializable id,
263: LockMode lockMode) throws HibernateException {
264:
265: return _session.load(theClass, id, lockMode);
266: }
267:
268: public Object load(String entityName, Serializable id,
269: LockMode lockMode) throws HibernateException {
270:
271: return _session.load(entityName, id, lockMode);
272: }
273:
274: public Object load(Class theClass, Serializable id)
275: throws HibernateException {
276:
277: return _session.load(theClass, id);
278: }
279:
280: public Object load(String entityName, Serializable id)
281: throws HibernateException {
282:
283: return _session.load(entityName, id);
284: }
285:
286: public void load(Object object, Serializable id)
287: throws HibernateException {
288: _session.load(object, id);
289: }
290:
291: public void lock(Object object, LockMode lockMode)
292: throws HibernateException {
293:
294: _session.lock(object, lockMode);
295: }
296:
297: public void lock(String entityName, Object object, LockMode lockMode)
298: throws HibernateException {
299:
300: _session.lock(entityName, object, lockMode);
301: }
302:
303: public Object merge(Object object) throws HibernateException {
304: return _session.merge(object);
305: }
306:
307: public Object merge(String entityName, Object object)
308: throws HibernateException {
309:
310: return _session.merge(entityName, object);
311: }
312:
313: public void persist(Object object) throws HibernateException {
314: _session.persist(object);
315: }
316:
317: public void persist(String entityName, Object object)
318: throws HibernateException {
319:
320: _session.persist(entityName, object);
321: }
322:
323: /**
324: * @deprecated
325: */
326: public void reconnect() throws HibernateException {
327: _session.reconnect();
328: }
329:
330: public void reconnect(Connection connection)
331: throws HibernateException {
332: _session.reconnect(connection);
333: }
334:
335: public void refresh(Object object) throws HibernateException {
336: _session.refresh(object);
337: }
338:
339: public void refresh(Object object, LockMode lockMode)
340: throws HibernateException {
341:
342: _session.refresh(object, lockMode);
343: }
344:
345: public void replicate(Object object, ReplicationMode replicationMode)
346: throws HibernateException {
347:
348: _session.replicate(object, replicationMode);
349: }
350:
351: public void replicate(String entityName, Object object,
352: ReplicationMode replicationMode) throws HibernateException {
353:
354: _session.replicate(entityName, object, replicationMode);
355: }
356:
357: public Serializable save(Object object) throws HibernateException {
358: return _session.save(object);
359: }
360:
361: public Serializable save(String entityName, Object object)
362: throws HibernateException {
363: return _session.save(entityName, object);
364: }
365:
366: public void saveOrUpdate(Object object) throws HibernateException {
367: _session.saveOrUpdate(object);
368: }
369:
370: public void saveOrUpdate(String entityName, Object object)
371: throws HibernateException {
372:
373: _session.saveOrUpdate(entityName, object);
374: }
375:
376: public void setCacheMode(CacheMode cacheMode) {
377: _session.setCacheMode(cacheMode);
378: }
379:
380: public void setFlushMode(FlushMode flushMode) {
381: _session.setFlushMode(flushMode);
382: }
383:
384: public void setReadOnly(Object entity, boolean readOnly) {
385: _session.setReadOnly(entity, readOnly);
386: }
387:
388: public void update(Object object) throws HibernateException {
389: _session.update(object);
390: }
391:
392: public void update(String entityName, Object object)
393: throws HibernateException {
394:
395: _session.update(entityName, object);
396: }
397:
398: private Session _session;
399:
400: }
|