/home/mario/oci/jnb/dataaccess/source/src/java/com/ociweb/service/QueryImpl.java

1    /** 
2     * This software program, Simple Data Access Layer (SDAL), is copyrighted by Object 
3     * Computing inc of St. Louis MO USA. It is provided under the open-source model 
4     * and is free of license fees. You are free to modify this code for your own use 
5     * but you may not claim copyright. 
6     * 
7     * Since SDAL is open source and free of licensing fees, you are free to use, 
8     * modify, and distribute the source code, as long as you include this copyright 
9     * statement. 
10    * 
11    * In particular, you can use SDAL to build proprietary software and are under no 
12    * obligation to redistribute any of your source code that is built using SDAL. 
13    * Note, however, that you may not do anything to the SDAL code, such as 
14    * copyrighting it yourself or claiming authorship of the SDAL code, that will 
15    * prevent SDAL from being distributed freely using an open source development 
16    * model. 
17    * 
18    * Warranty 
19    * LICENSED PRODUCT, SDAL, IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 
20    * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE, 
21    * NONINFRINGEMENT, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 
22    * 
23    * Support 
24    * LICENSED PRODUCT, SDAL, IS PROVIDED WITH NO SUPPORT AND WITHOUT ANY OBLIGATION ON THE 
25    * PART OF OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES TO ASSIST IN ITS USE, 
26    * CORRECTION, MODIFICATION OR ENHANCEMENT. 
27    * 
28    * Support may be available from OCI to users who have agreed to a support 
29    * contract. 
30    * 
31    * Liability 
32    * OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH 
33    * RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY 
34    * LICENSED PRODUCT OR ANY PART THEREOF. 
35    * 
36    * IN NO EVENT WILL OCI OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR ANY 
37    * LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL DAMAGES, 
38    * EVEN IF OCI HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
39    * 
40    * Copyright OCI. St. Louis MO USA, 2004 
41    * 
42    */ 
43   package com.ociweb.service; 
44    
45   import net.sf.hibernate.HibernateException; 
46    
47   import java.util.List; 
48   import java.util.Collection; 
49   import java.util.Locale; 
50   import java.util.Date; 
51   import java.util.Calendar; 
52   import java.io.Serializable; 
53   import java.math.BigDecimal; 
54    
55   import com.ociweb.service.LookupException; 
56   import com.ociweb.service.Query; 
57    
58   class QueryImpl implements Query{ 
59       private net.sf.hibernate.Query query; 
60    
61       QueryImpl(net.sf.hibernate.Query query) { 
62           this.query = query; 
63       } 
64       public List execute() throws LookupException { 
65           try { 
66               return query.list(); 
67           } catch (HibernateException e) { 
68               throw new LookupException("Unable to execute the Query", e); 
69           } 
70       } 
71    
72       public void setFirstResult(int firstResult) { 
73           query.setFirstResult(firstResult); 
74       } 
75    
76       public void setMaxResults(int maxResults) { 
77           query.setMaxResults(maxResults); 
78       } 
79    
80       public Query setParameter(int i, Object o) throws LookupException { 
81           try { 
82               query.setParameter(i, o); 
83           } catch (HibernateException e) { 
84               throw exceptionFactory(e); 
85           } 
86           return this; 
87       } 
88    
89       public Query setParameter(String s, Object o) throws LookupException { 
90           try { 
91               query.setParameter(s, o); 
92           } catch (HibernateException e) { 
93               throw exceptionFactory(e); 
94           } 
95           return this; 
96       } 
97    
98       public Query setParameterList(String s, Collection collection) throws LookupException { 
99           try { 
100              query.setParameterList(s, collection); 
101          } catch (HibernateException e) { 
102              throw exceptionFactory(e); 
103          } 
104          return this; 
105      } 
106   
107      public Query setParameterList(String s, Object[] objects) throws LookupException { 
108          try { 
109              query.setParameterList(s, objects); 
110          } catch (HibernateException e) { 
111              throw exceptionFactory(e); 
112          } 
113          return this; 
114      } 
115   
116      public Query setProperties(Object o) throws LookupException { 
117          try { 
118              query.setProperties(o); 
119          } catch (HibernateException e) { 
120              throw exceptionFactory(e); 
121          } 
122          return this; 
123      } 
124   
125      public Query setString(int i, String s) { 
126          query.setString(i, s); 
127          return this; 
128      } 
129   
130      public Query setCharacter(int i, char c) { 
131          query.setCharacter(i, c); 
132          return this; 
133      } 
134   
135      public Query setBoolean(int i, boolean b) { 
136          query.setBoolean(i, b); 
137          return this; 
138      } 
139   
140      public Query setByte(int i, byte b) { 
141          query.setByte(i, b); 
142          return this; 
143      } 
144   
145      public Query setShort(int i, short i1) { 
146          query.setShort(i, i1); 
147          return this; 
148      } 
149   
150      public Query setInteger(int i, int i1) { 
151          query.setInteger(i, i1); 
152          return this; 
153      } 
154   
155      public Query setLong(int i, long l) { 
156          query.setLong(i, l); 
157          return this; 
158      } 
159   
160      public Query setFloat(int i, float v) { 
161          query.setFloat(i, v); 
162          return this; 
163      } 
164   
165      public Query setDouble(int i, double v) { 
166          query.setDouble(i, v); 
167          return this; 
168      } 
169   
170      public Query setBinary(int i, byte[] bytes) { 
171          query.setBinary(i, bytes); 
172          return this; 
173      } 
174   
175      public Query setSerializable(int i, Serializable serializable) { 
176          query.setSerializable(i, serializable); 
177          return this; 
178      } 
179   
180      public Query setLocale(int i, Locale locale) { 
181          query.setLocale(i, locale); 
182          return this; 
183      } 
184   
185      public Query setBigDecimal(int i, BigDecimal bigDecimal) { 
186          query.setBigDecimal(i, bigDecimal); 
187          return this; 
188      } 
189   
190      public Query setDate(int i, Date date) { 
191          query.setDate(i, date); 
192          return this; 
193      } 
194   
195      public Query setTime(int i, Date date) { 
196          query.setTime(i, date); 
197          return this; 
198      } 
199   
200      public Query setTimestamp(int i, Date date) { 
201          query.setTimestamp(i, date); 
202          return this; 
203      } 
204   
205      public Query setCalendar(int i, Calendar calendar) { 
206          query.setCalendar(i, calendar); 
207          return this; 
208      } 
209   
210      public Query setCalendarDate(int i, Calendar calendar) { 
211          query.setCalendarDate(i, calendar); 
212          return this; 
213      } 
214   
215      public Query setString(String s, String s1) { 
216          query.setString(s, s1); 
217          return this; 
218      } 
219   
220      public Query setCharacter(String s, char c) { 
221          query.setCharacter(s, c); 
222          return this; 
223      } 
224   
225      public Query setBoolean(String s, boolean b) { 
226          query.setBoolean(s, b); 
227          return this; 
228      } 
229   
230      public Query setByte(String s, byte b) { 
231          query.setByte(s, b); 
232          return this; 
233      } 
234   
235      public Query setShort(String s, short i) { 
236          query.setShort(s, i); 
237          return this; 
238      } 
239   
240      public Query setInteger(String s, int i) { 
241          query.setInteger(s, i); 
242          return this; 
243      } 
244   
245      public Query setLong(String s, long l) { 
246          query.setLong(s, l); 
247          return this; 
248      } 
249   
250      public Query setFloat(String s, float v) { 
251          query.setFloat(s, v); 
252          return this; 
253      } 
254   
255      public Query setDouble(String s, double v) { 
256          query.setDouble(s, v); 
257          return this; 
258      } 
259   
260      public Query setBinary(String s, byte[] bytes) { 
261          query.setBinary(s, bytes); 
262          return this; 
263      } 
264   
265      public Query setSerializable(String s, Serializable serializable) { 
266          query.setSerializable(s, serializable); 
267          return this; 
268      } 
269   
270      public Query setLocale(String s, Locale locale) { 
271          query.setLocale(s, locale); 
272          return this; 
273      } 
274   
275      public Query setBigDecimal(String s, BigDecimal bigDecimal) { 
276          query.setBigDecimal(s, bigDecimal); 
277          return this; 
278      } 
279   
280      public Query setDate(String s, Date date) { 
281          query.setDate(s, date); 
282          return this; 
283      } 
284   
285      public Query setTime(String s, Date date) { 
286          query.setTime(s, date); 
287          return this; 
288      } 
289   
290      public Query setTimestamp(String s, Date date) { 
291          query.setTimestamp(s, date); 
292          return this; 
293      } 
294   
295      public Query setCalendar(String s, Calendar calendar) { 
296          query.setCalendar(s, calendar); 
297          return this; 
298      } 
299   
300      public Query setCalendarDate(String s, Calendar calendar) { 
301          query.setCalendarDate(s, calendar); 
302          return this; 
303      } 
304   
305      public Query setEntity(int i, Object o) { 
306          query.setEntity(i, o); 
307          return this; 
308      } 
309   
310      public Query setEntity(String s, Object o) { 
311          query.setEntity(s, o); 
312          return this; 
313      } 
314   
315      private LookupException exceptionFactory(Exception e) { 
316          return new LookupException("Unable to build query", e); 
317      } 
318  } 
319