Source Code Cross Referenced for AbstractScrollableResults.java in  » Database-ORM » hibernate » org » hibernate » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database ORM » hibernate » org.hibernate.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: AbstractScrollableResults.java 7469 2005-07-14 13:12:19Z steveebersole $
002:        package org.hibernate.impl;
003:
004:        import java.math.BigDecimal;
005:        import java.math.BigInteger;
006:        import java.sql.Blob;
007:        import java.sql.Clob;
008:        import java.sql.PreparedStatement;
009:        import java.sql.ResultSet;
010:        import java.sql.SQLException;
011:        import java.util.Calendar;
012:        import java.util.Date;
013:        import java.util.Locale;
014:        import java.util.TimeZone;
015:
016:        import org.hibernate.Hibernate;
017:        import org.hibernate.HibernateException;
018:        import org.hibernate.MappingException;
019:        import org.hibernate.ScrollableResults;
020:        import org.hibernate.engine.QueryParameters;
021:        import org.hibernate.engine.SessionImplementor;
022:        import org.hibernate.exception.JDBCExceptionHelper;
023:        import org.hibernate.hql.HolderInstantiator;
024:        import org.hibernate.loader.Loader;
025:        import org.hibernate.type.Type;
026:
027:        /**
028:         * Implementation of the <tt>ScrollableResults</tt> interface
029:         *
030:         * @author Steve Ebersole
031:         */
032:        public abstract class AbstractScrollableResults implements 
033:                ScrollableResults {
034:
035:            private final ResultSet resultSet;
036:            private final PreparedStatement ps;
037:            private final SessionImplementor session;
038:            private final Loader loader;
039:            private final QueryParameters queryParameters;
040:            private final Type[] types;
041:            private HolderInstantiator holderInstantiator;
042:
043:            public AbstractScrollableResults(ResultSet rs,
044:                    PreparedStatement ps, SessionImplementor sess,
045:                    Loader loader, QueryParameters queryParameters,
046:                    Type[] types, HolderInstantiator holderInstantiator)
047:                    throws MappingException {
048:                this .resultSet = rs;
049:                this .ps = ps;
050:                this .session = sess;
051:                this .loader = loader;
052:                this .queryParameters = queryParameters;
053:                this .types = types;
054:                this .holderInstantiator = holderInstantiator != null
055:                        && holderInstantiator.isRequired() ? holderInstantiator
056:                        : null;
057:            }
058:
059:            protected abstract Object[] getCurrentRow();
060:
061:            protected ResultSet getResultSet() {
062:                return resultSet;
063:            }
064:
065:            protected PreparedStatement getPs() {
066:                return ps;
067:            }
068:
069:            protected SessionImplementor getSession() {
070:                return session;
071:            }
072:
073:            protected Loader getLoader() {
074:                return loader;
075:            }
076:
077:            protected QueryParameters getQueryParameters() {
078:                return queryParameters;
079:            }
080:
081:            protected Type[] getTypes() {
082:                return types;
083:            }
084:
085:            protected HolderInstantiator getHolderInstantiator() {
086:                return holderInstantiator;
087:            }
088:
089:            public final void close() throws HibernateException {
090:                try {
091:                    // not absolutely necessary, but does help with aggressive release
092:                    session.getBatcher().closeQueryStatement(ps, resultSet);
093:                } catch (SQLException sqle) {
094:                    throw JDBCExceptionHelper.convert(session.getFactory()
095:                            .getSQLExceptionConverter(), sqle,
096:                            "could not close results");
097:                }
098:            }
099:
100:            public final Object[] get() throws HibernateException {
101:                return getCurrentRow();
102:            }
103:
104:            public final Object get(int col) throws HibernateException {
105:                return getCurrentRow()[col];
106:            }
107:
108:            /**
109:             * Check that the requested type is compatible with the result type, and
110:             * return the column value.  This version makes sure the the classes
111:             * are identical.
112:             *
113:             * @param col the column
114:             * @param returnType a "final" type
115:             */
116:            protected final Object getFinal(int col, Type returnType)
117:                    throws HibernateException {
118:                if (holderInstantiator != null) {
119:                    throw new HibernateException(
120:                            "query specifies a holder class");
121:                }
122:
123:                if (returnType.getReturnedClass() == types[col]
124:                        .getReturnedClass()) {
125:                    return get(col);
126:                } else {
127:                    return throwInvalidColumnTypeException(col, types[col],
128:                            returnType);
129:                }
130:            }
131:
132:            /**
133:             * Check that the requested type is compatible with the result type, and
134:             * return the column value.  This version makes sure the the classes
135:             * are "assignable".
136:             *
137:             * @param col the column
138:             * @param returnType any type
139:             */
140:            protected final Object getNonFinal(int col, Type returnType)
141:                    throws HibernateException {
142:                if (holderInstantiator != null) {
143:                    throw new HibernateException(
144:                            "query specifies a holder class");
145:                }
146:
147:                if (returnType.getReturnedClass().isAssignableFrom(
148:                        types[col].getReturnedClass())) {
149:                    return get(col);
150:                } else {
151:                    return throwInvalidColumnTypeException(col, types[col],
152:                            returnType);
153:                }
154:            }
155:
156:            public final BigDecimal getBigDecimal(int col)
157:                    throws HibernateException {
158:                return (BigDecimal) getFinal(col, Hibernate.BIG_DECIMAL);
159:            }
160:
161:            public final BigInteger getBigInteger(int col)
162:                    throws HibernateException {
163:                return (BigInteger) getFinal(col, Hibernate.BIG_INTEGER);
164:            }
165:
166:            public final byte[] getBinary(int col) throws HibernateException {
167:                return (byte[]) getFinal(col, Hibernate.BINARY);
168:            }
169:
170:            public final String getText(int col) throws HibernateException {
171:                return (String) getFinal(col, Hibernate.TEXT);
172:            }
173:
174:            public final Blob getBlob(int col) throws HibernateException {
175:                return (Blob) getNonFinal(col, Hibernate.BLOB);
176:            }
177:
178:            public final Clob getClob(int col) throws HibernateException {
179:                return (Clob) getNonFinal(col, Hibernate.CLOB);
180:            }
181:
182:            public final Boolean getBoolean(int col) throws HibernateException {
183:                return (Boolean) getFinal(col, Hibernate.BOOLEAN);
184:            }
185:
186:            public final Byte getByte(int col) throws HibernateException {
187:                return (Byte) getFinal(col, Hibernate.BYTE);
188:            }
189:
190:            public final Character getCharacter(int col)
191:                    throws HibernateException {
192:                return (Character) getFinal(col, Hibernate.CHARACTER);
193:            }
194:
195:            public final Date getDate(int col) throws HibernateException {
196:                return (Date) getNonFinal(col, Hibernate.TIMESTAMP);
197:            }
198:
199:            public final Calendar getCalendar(int col)
200:                    throws HibernateException {
201:                return (Calendar) getNonFinal(col, Hibernate.CALENDAR);
202:            }
203:
204:            public final Double getDouble(int col) throws HibernateException {
205:                return (Double) getFinal(col, Hibernate.DOUBLE);
206:            }
207:
208:            public final Float getFloat(int col) throws HibernateException {
209:                return (Float) getFinal(col, Hibernate.FLOAT);
210:            }
211:
212:            public final Integer getInteger(int col) throws HibernateException {
213:                return (Integer) getFinal(col, Hibernate.INTEGER);
214:            }
215:
216:            public final Long getLong(int col) throws HibernateException {
217:                return (Long) getFinal(col, Hibernate.LONG);
218:            }
219:
220:            public final Short getShort(int col) throws HibernateException {
221:                return (Short) getFinal(col, Hibernate.SHORT);
222:            }
223:
224:            public final String getString(int col) throws HibernateException {
225:                return (String) getFinal(col, Hibernate.STRING);
226:            }
227:
228:            public final Locale getLocale(int col) throws HibernateException {
229:                return (Locale) getFinal(col, Hibernate.LOCALE);
230:            }
231:
232:            /*public final Currency getCurrency(int col) throws HibernateException {
233:            	return (Currency) get(col);
234:            }*/
235:
236:            public final TimeZone getTimeZone(int col)
237:                    throws HibernateException {
238:                return (TimeZone) getNonFinal(col, Hibernate.TIMEZONE);
239:            }
240:
241:            public final Type getType(int i) {
242:                return types[i];
243:            }
244:
245:            private Object throwInvalidColumnTypeException(int i, Type type,
246:                    Type returnType) throws HibernateException {
247:                throw new HibernateException("incompatible column types: "
248:                        + type.getName() + ", " + returnType.getName());
249:            }
250:
251:            protected void afterScrollOperation() {
252:                session.afterScrollOperation();
253:            }
254:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.