Source Code Cross Referenced for ScrollableResultsImpl.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: ScrollableResultsImpl.java 7469 2005-07-14 13:12:19Z steveebersole $
002:        package org.hibernate.impl;
003:
004:        import org.hibernate.HibernateException;
005:        import org.hibernate.MappingException;
006:        import org.hibernate.ScrollableResults;
007:        import org.hibernate.engine.QueryParameters;
008:        import org.hibernate.engine.SessionImplementor;
009:        import org.hibernate.exception.JDBCExceptionHelper;
010:        import org.hibernate.hql.HolderInstantiator;
011:        import org.hibernate.loader.Loader;
012:        import org.hibernate.type.Type;
013:
014:        import java.sql.PreparedStatement;
015:        import java.sql.ResultSet;
016:        import java.sql.SQLException;
017:
018:        /**
019:         * Implementation of the <tt>ScrollableResults</tt> interface
020:         * @author Gavin King
021:         */
022:        public class ScrollableResultsImpl extends AbstractScrollableResults
023:                implements  ScrollableResults {
024:
025:            private Object[] currentRow;
026:
027:            public ScrollableResultsImpl(ResultSet rs, PreparedStatement ps,
028:                    SessionImplementor sess, Loader loader,
029:                    QueryParameters queryParameters, Type[] types,
030:                    HolderInstantiator holderInstantiator)
031:                    throws MappingException {
032:                super (rs, ps, sess, loader, queryParameters, types,
033:                        holderInstantiator);
034:            }
035:
036:            protected Object[] getCurrentRow() {
037:                return currentRow;
038:            }
039:
040:            /**
041:             * @see org.hibernate.ScrollableResults#scroll(int)
042:             */
043:            public boolean scroll(int i) throws HibernateException {
044:                try {
045:                    boolean result = getResultSet().relative(i);
046:                    prepareCurrentRow(result);
047:                    return result;
048:                } catch (SQLException sqle) {
049:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
050:                            .getSQLExceptionConverter(), sqle,
051:                            "could not advance using scroll()");
052:                }
053:            }
054:
055:            /**
056:             * @see org.hibernate.ScrollableResults#first()
057:             */
058:            public boolean first() throws HibernateException {
059:                try {
060:                    boolean result = getResultSet().first();
061:                    prepareCurrentRow(result);
062:                    return result;
063:                } catch (SQLException sqle) {
064:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
065:                            .getSQLExceptionConverter(), sqle,
066:                            "could not advance using first()");
067:                }
068:            }
069:
070:            /**
071:             * @see org.hibernate.ScrollableResults#last()
072:             */
073:            public boolean last() throws HibernateException {
074:                try {
075:                    boolean result = getResultSet().last();
076:                    prepareCurrentRow(result);
077:                    return result;
078:                } catch (SQLException sqle) {
079:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
080:                            .getSQLExceptionConverter(), sqle,
081:                            "could not advance using last()");
082:                }
083:            }
084:
085:            /**
086:             * @see org.hibernate.ScrollableResults#next()
087:             */
088:            public boolean next() throws HibernateException {
089:                try {
090:                    boolean result = getResultSet().next();
091:                    prepareCurrentRow(result);
092:                    return result;
093:                } catch (SQLException sqle) {
094:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
095:                            .getSQLExceptionConverter(), sqle,
096:                            "could not advance using next()");
097:                }
098:            }
099:
100:            /**
101:             * @see org.hibernate.ScrollableResults#previous()
102:             */
103:            public boolean previous() throws HibernateException {
104:                try {
105:                    boolean result = getResultSet().previous();
106:                    prepareCurrentRow(result);
107:                    return result;
108:                } catch (SQLException sqle) {
109:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
110:                            .getSQLExceptionConverter(), sqle,
111:                            "could not advance using previous()");
112:                }
113:            }
114:
115:            /**
116:             * @see org.hibernate.ScrollableResults#afterLast()
117:             */
118:            public void afterLast() throws HibernateException {
119:                try {
120:                    getResultSet().afterLast();
121:                } catch (SQLException sqle) {
122:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
123:                            .getSQLExceptionConverter(), sqle,
124:                            "exception calling afterLast()");
125:                }
126:            }
127:
128:            /**
129:             * @see org.hibernate.ScrollableResults#beforeFirst()
130:             */
131:            public void beforeFirst() throws HibernateException {
132:                try {
133:                    getResultSet().beforeFirst();
134:                } catch (SQLException sqle) {
135:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
136:                            .getSQLExceptionConverter(), sqle,
137:                            "exception calling beforeFirst()");
138:                }
139:            }
140:
141:            /**
142:             * @see org.hibernate.ScrollableResults#isFirst()
143:             */
144:            public boolean isFirst() throws HibernateException {
145:                try {
146:                    return getResultSet().isFirst();
147:                } catch (SQLException sqle) {
148:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
149:                            .getSQLExceptionConverter(), sqle,
150:                            "exception calling isFirst()");
151:                }
152:            }
153:
154:            /**
155:             * @see org.hibernate.ScrollableResults#isLast()
156:             */
157:            public boolean isLast() throws HibernateException {
158:                try {
159:                    return getResultSet().isLast();
160:                } catch (SQLException sqle) {
161:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
162:                            .getSQLExceptionConverter(), sqle,
163:                            "exception calling isLast()");
164:                }
165:            }
166:
167:            public int getRowNumber() throws HibernateException {
168:                try {
169:                    return getResultSet().getRow() - 1;
170:                } catch (SQLException sqle) {
171:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
172:                            .getSQLExceptionConverter(), sqle,
173:                            "exception calling getRow()");
174:                }
175:            }
176:
177:            public boolean setRowNumber(int rowNumber)
178:                    throws HibernateException {
179:                if (rowNumber >= 0)
180:                    rowNumber++;
181:                try {
182:                    boolean result = getResultSet().absolute(rowNumber);
183:                    prepareCurrentRow(result);
184:                    return result;
185:                } catch (SQLException sqle) {
186:                    throw JDBCExceptionHelper.convert(getSession().getFactory()
187:                            .getSQLExceptionConverter(), sqle,
188:                            "could not advance using absolute()");
189:                }
190:            }
191:
192:            private void prepareCurrentRow(boolean underlyingScrollSuccessful)
193:                    throws HibernateException {
194:
195:                if (!underlyingScrollSuccessful) {
196:                    currentRow = null;
197:                    return;
198:                }
199:
200:                Object result = getLoader().loadSingleRow(getResultSet(),
201:                        getSession(), getQueryParameters(), false);
202:                if (result != null && result.getClass().isArray()) {
203:                    currentRow = (Object[]) result;
204:                } else {
205:                    currentRow = new Object[] { result };
206:                }
207:
208:                if (getHolderInstantiator() != null) {
209:                    currentRow = new Object[] { getHolderInstantiator()
210:                            .instantiate(currentRow) };
211:                }
212:
213:                afterScrollOperation();
214:            }
215:
216:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.