1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.dao.orm.hibernate;
24  
25  import com.liferay.portal.kernel.dao.orm.ORMException;
26  import com.liferay.portal.kernel.dao.orm.Query;
27  import com.liferay.portal.kernel.dao.orm.ScrollableResults;
28  
29  import java.io.Serializable;
30  
31  import java.sql.Timestamp;
32  
33  import java.util.Iterator;
34  import java.util.List;
35  
36  /**
37   * <a href="QueryImpl.java.html"><b><i>View Source</i></b></a>
38   *
39   * @author Brian Wing Shun Chan
40   *
41   */
42  public class QueryImpl implements Query {
43  
44      public QueryImpl(org.hibernate.Query query) {
45          _query = query;
46      }
47  
48      public Iterator iterate() throws ORMException {
49          try {
50              return _query.iterate();
51          }
52          catch (Exception e) {
53              throw ExceptionTranslator.translate(e);
54          }
55      }
56  
57      public List list() throws ORMException {
58          try {
59              return _query.list();
60          }
61          catch (Exception e) {
62              throw ExceptionTranslator.translate(e);
63          }
64      }
65  
66      public ScrollableResults scroll() throws ORMException {
67          try {
68              return new ScrollableResultsImpl(_query.scroll());
69          }
70          catch (Exception e) {
71              throw ExceptionTranslator.translate(e);
72          }
73      }
74  
75      public Query setBoolean(int pos, boolean value) {
76          _query.setBoolean(pos, value);
77  
78          return this;
79      }
80  
81      public Query setDouble(int pos, double value) {
82          _query.setDouble(pos, value);
83  
84          return this;
85      }
86  
87      public Query setFirstResult(int firstResult) {
88          _query.setFirstResult(firstResult);
89  
90          return this;
91      }
92  
93      public Query setFloat(int pos, float value) {
94          _query.setFloat(pos, value);
95  
96          return this;
97      }
98  
99      public Query setInteger(int pos, int value) {
100         _query.setInteger(pos, value);
101 
102         return this;
103     }
104 
105     public Query setLong(int pos, long value) {
106         _query.setLong(pos, value);
107 
108         return this;
109     }
110 
111     public Query setMaxResults(int maxResults) {
112         _query.setMaxResults(maxResults);
113 
114         return this;
115     }
116 
117     public Query setSerializable(int pos, Serializable value) {
118         _query.setSerializable(pos, value);
119 
120         return this;
121     }
122 
123     public Query setShort(int pos, short value) {
124         _query.setShort(pos, value);
125 
126         return this;
127     }
128 
129     public Query setString(int pos, String value) {
130         _query.setString(pos, value);
131 
132         return this;
133     }
134 
135     public Query setTimestamp(int pos, Timestamp value) {
136         _query.setTimestamp(pos, value);
137 
138         return this;
139     }
140 
141     public Object uniqueResult() throws ORMException {
142         try {
143             return _query.uniqueResult();
144         }
145         catch (Exception e) {
146             throw ExceptionTranslator.translate(e);
147         }
148     }
149 
150     private org.hibernate.Query _query;
151 
152 }