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