Source Code Cross Referenced for SelectResultObjectProvider.java in  » Database-ORM » openjpa » org » apache » openjpa » jdbc » kernel » 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 » openjpa » org.apache.openjpa.jdbc.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:        package org.apache.openjpa.jdbc.kernel;
020:
021:        import java.sql.SQLException;
022:
023:        import org.apache.openjpa.jdbc.sql.Result;
024:        import org.apache.openjpa.jdbc.sql.SQLExceptions;
025:        import org.apache.openjpa.jdbc.sql.Select;
026:        import org.apache.openjpa.jdbc.sql.SelectExecutor;
027:        import org.apache.openjpa.lib.rop.ResultObjectProvider;
028:        import org.apache.openjpa.util.StoreException;
029:
030:        /**
031:         * Abstract provider implementation wrapped around a {@link Select}.
032:         *
033:         * @author Abe White
034:         * @nojavadoc
035:         */
036:        public abstract class SelectResultObjectProvider implements 
037:                ResultObjectProvider {
038:
039:            private final SelectExecutor _sel;
040:            private final JDBCStore _store;
041:            private final JDBCFetchConfiguration _fetch;
042:            private Result _res = null;
043:            private int _size = -1;
044:            private Boolean _ra = null;
045:
046:            /**
047:             * Constructor.
048:             *
049:             * @param sel the select to execute
050:             * @param store the store to delegate loading to
051:             * @param fetch the fetch configuration, or null for the default
052:             */
053:            public SelectResultObjectProvider(SelectExecutor sel,
054:                    JDBCStore store, JDBCFetchConfiguration fetch) {
055:                _sel = sel;
056:                _store = store;
057:                _fetch = fetch;
058:            }
059:
060:            public SelectExecutor getSelect() {
061:                return _sel;
062:            }
063:
064:            public JDBCStore getStore() {
065:                return _store;
066:            }
067:
068:            public JDBCFetchConfiguration getFetchConfiguration() {
069:                return _fetch;
070:            }
071:
072:            public Result getResult() {
073:                return _res;
074:            }
075:
076:            public boolean supportsRandomAccess() {
077:                if (_ra == null) {
078:                    boolean ra;
079:                    if (_res != null) {
080:                        try {
081:                            ra = _res.supportsRandomAccess();
082:                        } catch (SQLException se) {
083:                            throw SQLExceptions.getStore(se, _store
084:                                    .getDBDictionary());
085:                        }
086:                    } else
087:                        ra = _sel.supportsRandomAccess(_fetch
088:                                .getReadLockLevel() > 0);
089:                    _ra = (ra) ? Boolean.TRUE : Boolean.FALSE;
090:                }
091:                return _ra.booleanValue();
092:            }
093:
094:            public void open() throws SQLException {
095:                _res = _sel.execute(_store, _fetch);
096:            }
097:
098:            public boolean next() throws SQLException {
099:                return _res.next();
100:            }
101:
102:            public boolean absolute(int pos) throws SQLException {
103:                return _res.absolute(pos);
104:            }
105:
106:            public int size() throws SQLException {
107:                if (_size == -1) {
108:                    // if res is null, don't cache size
109:                    if (_res == null)
110:                        return Integer.MAX_VALUE;
111:
112:                    switch (_fetch.getLRSSize()) {
113:                    case LRSSizes.SIZE_UNKNOWN:
114:                        _size = Integer.MAX_VALUE;
115:                        break;
116:                    case LRSSizes.SIZE_LAST:
117:                        if (supportsRandomAccess())
118:                            _size = _res.size();
119:                        else
120:                            _size = Integer.MAX_VALUE;
121:                        break;
122:                    default: // query
123:                        _size = _sel.getCount(_store);
124:                    }
125:                }
126:                return _size;
127:            }
128:
129:            /**
130:             * Allow subclasses that know the size to set it; otherwise we calculate
131:             * it internally.
132:             */
133:            protected void setSize(int size) {
134:                if (_size == -1)
135:                    _size = size;
136:            }
137:
138:            public void reset() throws SQLException {
139:                close();
140:                open();
141:            }
142:
143:            public void close() {
144:                if (_res != null) {
145:                    _res.close();
146:                    _res = null;
147:                }
148:            }
149:
150:            public void handleCheckedException(Exception e) {
151:                if (e instanceof  SQLException)
152:                    throw SQLExceptions.getStore((SQLException) e, _store
153:                            .getDBDictionary());
154:                throw new StoreException(e);
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.