1
19
20 package com.liferay.portal.dao.orm.hibernate;
21
22 import com.liferay.portal.kernel.dao.orm.CacheMode;
23 import com.liferay.portal.kernel.dao.orm.ORMException;
24 import com.liferay.portal.kernel.dao.orm.Query;
25 import com.liferay.portal.kernel.dao.orm.ScrollableResults;
26 import com.liferay.portal.kernel.util.ListUtil;
27 import com.liferay.portal.kernel.util.UnmodifiableList;
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
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 return iterate(true);
59 }
60
61 public Iterator iterate(boolean unmodifiable) throws ORMException {
62 try {
63 return list(unmodifiable).iterator();
64 }
65 catch (Exception e) {
66 throw ExceptionTranslator.translate(e);
67 }
68 }
69
70 public List list() throws ORMException {
71 return list(true);
72 }
73
74 public List list(boolean unmodifiable) throws ORMException {
75 try {
76 List list = _query.list();
77
78 if (unmodifiable) {
79 return new UnmodifiableList(list);
80 }
81 else {
82 return ListUtil.copy(list);
83 }
84 }
85 catch (Exception e) {
86 throw ExceptionTranslator.translate(e);
87 }
88 }
89
90 public ScrollableResults scroll() throws ORMException {
91 try {
92 return new ScrollableResultsImpl(_query.scroll());
93 }
94 catch (Exception e) {
95 throw ExceptionTranslator.translate(e);
96 }
97 }
98
99 public Query setBoolean(int pos, boolean value) {
100 _query.setBoolean(pos, value);
101
102 return this;
103 }
104
105 public Query setCacheable(boolean cacheable) {
106 _query.setCacheable(cacheable);
107
108 return this;
109 }
110
111 public Query setCacheMode(CacheMode cacheMode) {
112 _query.setCacheMode(CacheModeTranslator.translate(cacheMode));
113
114 return this;
115 }
116
117 public Query setCacheRegion(String cacheRegion) {
118 _query.setCacheRegion(cacheRegion);
119
120 return this;
121 }
122
123 public Query setDouble(int pos, double value) {
124 _query.setDouble(pos, value);
125
126 return this;
127 }
128
129 public Query setFirstResult(int firstResult) {
130 _query.setFirstResult(firstResult);
131
132 return this;
133 }
134
135 public Query setFloat(int pos, float value) {
136 _query.setFloat(pos, value);
137
138 return this;
139 }
140
141 public Query setInteger(int pos, int value) {
142 _query.setInteger(pos, value);
143
144 return this;
145 }
146
147 public Query setLong(int pos, long value) {
148 _query.setLong(pos, value);
149
150 return this;
151 }
152
153 public Query setMaxResults(int maxResults) {
154 _query.setMaxResults(maxResults);
155
156 return this;
157 }
158
159 public Query setSerializable(int pos, Serializable value) {
160 _query.setSerializable(pos, value);
161
162 return this;
163 }
164
165 public Query setShort(int pos, short value) {
166 _query.setShort(pos, value);
167
168 return this;
169 }
170
171 public Query setString(int pos, String value) {
172 _query.setString(pos, value);
173
174 return this;
175 }
176
177 public Query setTimestamp(int pos, Timestamp value) {
178 _query.setTimestamp(pos, value);
179
180 return this;
181 }
182
183 public Object uniqueResult() throws ORMException {
184 try {
185 return _query.uniqueResult();
186 }
187 catch (Exception e) {
188 throw ExceptionTranslator.translate(e);
189 }
190 }
191
192 private org.hibernate.Query _query;
193
194 }