Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
33 | PointedEar | 1 | /* |
2 | * Hibernate, Relational Persistence for Idiomatic Java |
||
3 | * |
||
4 | * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as |
||
5 | * indicated by the @author tags or express copyright attribution |
||
6 | * statements applied by the authors. All third-party contributions are |
||
7 | * distributed under license by Red Hat Middleware LLC. |
||
8 | * |
||
9 | * This copyrighted material is made available to anyone wishing to use, modify, |
||
10 | * copy, or redistribute it subject to the terms and conditions of the GNU |
||
11 | * Lesser General Public License, as published by the Free Software Foundation. |
||
12 | * |
||
13 | * This program is distributed in the hope that it will be useful, |
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
||
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
||
16 | * for more details. |
||
17 | * |
||
18 | * You should have received a copy of the GNU Lesser General Public License |
||
19 | * along with this distribution; if not, write to: |
||
20 | * Free Software Foundation, Inc. |
||
21 | * 51 Franklin Street, Fifth Floor |
||
22 | * Boston, MA 02110-1301 USA |
||
23 | * |
||
24 | */ |
||
25 | package org.hibernate; |
||
26 | |||
27 | import java.math.BigDecimal; |
||
28 | import java.math.BigInteger; |
||
29 | import java.sql.Blob; |
||
30 | import java.sql.Clob; |
||
31 | import java.util.Calendar; |
||
32 | import java.util.Date; |
||
33 | import java.util.Locale; |
||
34 | import java.util.TimeZone; |
||
35 | |||
36 | import org.hibernate.type.Type; |
||
37 | |||
38 | /** |
||
39 | * A result iterator that allows moving around within the results |
||
40 | * by arbitrary increments. The <tt>Query</tt> / <tt>ScrollableResults</tt> |
||
41 | * pattern is very similar to the JDBC <tt>PreparedStatement</tt>/ |
||
42 | * <tt>ResultSet</tt> pattern and the semantics of methods of this interface |
||
43 | * are similar to the similarly named methods on <tt>ResultSet</tt>.<br> |
||
44 | * <br> |
||
45 | * Contrary to JDBC, columns of results are numbered from zero. |
||
46 | * |
||
47 | * @see Query#scroll() |
||
48 | * @author Gavin King |
||
49 | */ |
||
50 | public interface ScrollableResults { |
||
51 | /** |
||
52 | * Advance to the next result |
||
53 | * @return <tt>true</tt> if there is another result |
||
54 | */ |
||
55 | public boolean next() throws HibernateException; |
||
56 | /** |
||
57 | * Retreat to the previous result |
||
58 | * @return <tt>true</tt> if there is a previous result |
||
59 | */ |
||
60 | public boolean previous() throws HibernateException; |
||
61 | /** |
||
62 | * Scroll an arbitrary number of locations |
||
63 | * @param i a positive (forward) or negative (backward) number of rows |
||
64 | * @return <tt>true</tt> if there is a result at the new location |
||
65 | */ |
||
66 | public boolean scroll(int i) throws HibernateException; |
||
67 | /** |
||
68 | * Go to the last result |
||
69 | * @return <tt>true</tt> if there are any results |
||
70 | */ |
||
71 | public boolean last() throws HibernateException; |
||
72 | /** |
||
73 | * Go to the first result |
||
74 | * @return <tt>true</tt> if there are any results |
||
75 | */ |
||
76 | public boolean first() throws HibernateException; |
||
77 | /** |
||
78 | * Go to a location just before first result (this is the initial location) |
||
79 | */ |
||
80 | public void beforeFirst() throws HibernateException; |
||
81 | /** |
||
82 | * Go to a location just after the last result |
||
83 | */ |
||
84 | public void afterLast() throws HibernateException; |
||
85 | /** |
||
86 | * Is this the first result? |
||
87 | * |
||
88 | * @return <tt>true</tt> if this is the first row of results |
||
89 | * @throws HibernateException |
||
90 | */ |
||
91 | public boolean isFirst() throws HibernateException; |
||
92 | /** |
||
93 | * Is this the last result? |
||
94 | * |
||
95 | * @return <tt>true</tt> if this is the last row of results |
||
96 | * @throws HibernateException |
||
97 | */ |
||
98 | public boolean isLast() throws HibernateException; |
||
99 | /** |
||
100 | * Release resources immediately. |
||
101 | */ |
||
102 | public void close() throws HibernateException; |
||
103 | /** |
||
104 | * Get the current row of results |
||
105 | * @return an object or array |
||
106 | */ |
||
107 | public Object[] get() throws HibernateException; |
||
108 | /** |
||
109 | * Get the <tt>i</tt>th object in the current row of results, without |
||
110 | * initializing any other results in the row. This method may be used |
||
111 | * safely, regardless of the type of the column (ie. even for scalar |
||
112 | * results). |
||
113 | * @param i the column, numbered from zero |
||
114 | * @return an object of any Hibernate type or <tt>null</tt> |
||
115 | */ |
||
116 | public Object get(int i) throws HibernateException; |
||
117 | |||
118 | /** |
||
119 | * Get the type of the <tt>i</tt>th column of results |
||
120 | * @param i the column, numbered from zero |
||
121 | * @return the Hibernate type |
||
122 | */ |
||
123 | public Type getType(int i); |
||
124 | |||
125 | /** |
||
126 | * Convenience method to read an <tt>integer</tt> |
||
127 | */ |
||
128 | public Integer getInteger(int col) throws HibernateException; |
||
129 | /** |
||
130 | * Convenience method to read a <tt>long</tt> |
||
131 | */ |
||
132 | public Long getLong(int col) throws HibernateException; |
||
133 | /** |
||
134 | * Convenience method to read a <tt>float</tt> |
||
135 | */ |
||
136 | public Float getFloat(int col) throws HibernateException; |
||
137 | /** |
||
138 | * Convenience method to read a <tt>boolean</tt> |
||
139 | */ |
||
140 | public Boolean getBoolean(int col) throws HibernateException; |
||
141 | /** |
||
142 | * Convenience method to read a <tt>double</tt> |
||
143 | */ |
||
144 | public Double getDouble(int col) throws HibernateException; |
||
145 | /** |
||
146 | * Convenience method to read a <tt>short</tt> |
||
147 | */ |
||
148 | public Short getShort(int col) throws HibernateException; |
||
149 | /** |
||
150 | * Convenience method to read a <tt>byte</tt> |
||
151 | */ |
||
152 | public Byte getByte(int col) throws HibernateException; |
||
153 | /** |
||
154 | * Convenience method to read a <tt>character</tt> |
||
155 | */ |
||
156 | public Character getCharacter(int col) throws HibernateException; |
||
157 | /** |
||
158 | * Convenience method to read a <tt>binary</tt> |
||
159 | */ |
||
160 | public byte[] getBinary(int col) throws HibernateException; |
||
161 | /** |
||
162 | * Convenience method to read <tt>text</tt> |
||
163 | */ |
||
164 | public String getText(int col) throws HibernateException; |
||
165 | /** |
||
166 | * Convenience method to read a <tt>blob</tt> |
||
167 | */ |
||
168 | public Blob getBlob(int col) throws HibernateException; |
||
169 | /** |
||
170 | * Convenience method to read a <tt>clob</tt> |
||
171 | */ |
||
172 | public Clob getClob(int col) throws HibernateException; |
||
173 | /** |
||
174 | * Convenience method to read a <tt>string</tt> |
||
175 | */ |
||
176 | public String getString(int col) throws HibernateException; |
||
177 | /** |
||
178 | * Convenience method to read a <tt>big_decimal</tt> |
||
179 | */ |
||
180 | public BigDecimal getBigDecimal(int col) throws HibernateException; |
||
181 | /** |
||
182 | * Convenience method to read a <tt>big_integer</tt> |
||
183 | */ |
||
184 | public BigInteger getBigInteger(int col) throws HibernateException; |
||
185 | /** |
||
186 | * Convenience method to read a <tt>date</tt>, <tt>time</tt> or <tt>timestamp</tt> |
||
187 | */ |
||
188 | public Date getDate(int col) throws HibernateException; |
||
189 | /** |
||
190 | * Convenience method to read a <tt>locale</tt> |
||
191 | */ |
||
192 | public Locale getLocale(int col) throws HibernateException; |
||
193 | /** |
||
194 | * Convenience method to read a <tt>calendar</tt> or <tt>calendar_date</tt> |
||
195 | */ |
||
196 | public Calendar getCalendar(int col) throws HibernateException; |
||
197 | /** |
||
198 | * Convenience method to read a <tt>currency</tt> |
||
199 | */ |
||
200 | //public Currency getCurrency(int col) throws HibernateException; |
||
201 | /** |
||
202 | * Convenience method to read a <tt>timezone</tt> |
||
203 | */ |
||
204 | public TimeZone getTimeZone(int col) throws HibernateException; |
||
205 | /** |
||
206 | * Get the current location in the result set. The first |
||
207 | * row is number <tt>0</tt>, contrary to JDBC. |
||
208 | * @return the row number, numbered from <tt>0</tt>, or <tt>-1</tt> if |
||
209 | * there is no current row |
||
210 | */ |
||
211 | public int getRowNumber() throws HibernateException; |
||
212 | /** |
||
213 | * Set the current location in the result set, numbered from either the |
||
214 | * first row (row number <tt>0</tt>), or the last row (row |
||
215 | * number <tt>-1</tt>). |
||
216 | * @param rowNumber the row number, numbered from the last row, in the |
||
217 | * case of a negative row number |
||
218 | * @return true if there is a row at that row number |
||
219 | */ |
||
220 | public boolean setRowNumber(int rowNumber) throws HibernateException; |
||
221 | } |
||
222 | |||
223 | |||
224 | |||
225 | |||
226 | |||
227 |