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 int executeUpdate() throws ORMException {
49          try {
50              return _query.executeUpdate();
51          }
52          catch (Exception e) {
53              throw ExceptionTranslator.translate(e);
54          }
55      }
56  
57      public Iterator iterate() throws ORMException {
58          try {
59              return _query.iterate();
60          }
61          catch (Exception e) {
62              throw ExceptionTranslator.translate(e);
63          }
64      }
65  
66      public List list() throws ORMException {
67          try {
68              return _query.list();
69          }
70          catch (Exception e) {
71              throw ExceptionTranslator.translate(e);
72          }
73      }
74  
75      public ScrollableResults scroll() throws ORMException {
76          try {
77              return new ScrollableResultsImpl(_query.scroll());
78          }
79          catch (Exception e) {
80              throw ExceptionTranslator.translate(e);
81          }
82      }
83  
84      public Query setBoolean(int pos, boolean value) {
85          _query.setBoolean(pos, value);
86  
87          return this;
88      }
89  
90      public Query setDouble(int pos, double value) {
91          _query.setDouble(pos, value);
92  
93          return this;
94      }
95  
96      public Query setFirstResult(int firstResult) {
97          _query.setFirstResult(firstResult);
98  
99          return this;
100     }
101 
102     public Query setFloat(int pos, float value) {
103         _query.setFloat(pos, value);
104 
105         return this;
106     }
107 
108     public Query setInteger(int pos, int value) {
109         _query.setInteger(pos, value);
110 
111         return this;
112     }
113 
114     public Query setLong(int pos, long value) {
115         _query.setLong(pos, value);
116 
117         return this;
118     }
119 
120     public Query setMaxResults(int maxResults) {
121         _query.setMaxResults(maxResults);
122 
123         return this;
124     }
125 
126     public Query setSerializable(int pos, Serializable value) {
127         _query.setSerializable(pos, value);
128 
129         return this;
130     }
131 
132     public Query setShort(int pos, short value) {
133         _query.setShort(pos, value);
134 
135         return this;
136     }
137 
138     public Query setString(int pos, String value) {
139         _query.setString(pos, value);
140 
141         return this;
142     }
143 
144     public Query setTimestamp(int pos, Timestamp value) {
145         _query.setTimestamp(pos, value);
146 
147         return this;
148     }
149 
150     public Object uniqueResult() throws ORMException {
151         try {
152             return _query.uniqueResult();
153         }
154         catch (Exception e) {
155             throw ExceptionTranslator.translate(e);
156         }
157     }
158 
159     private org.hibernate.Query _query;
160 
161 }