Source Code Cross Referenced for AbstractSessionImpl.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: AbstractSessionImpl.java 10018 2006-06-15 05:21:06Z steve.ebersole@jboss.com $
002:        package org.hibernate.impl;
003:
004:        import org.hibernate.MappingException;
005:        import org.hibernate.Query;
006:        import org.hibernate.SQLQuery;
007:        import org.hibernate.HibernateException;
008:        import org.hibernate.ScrollableResults;
009:        import org.hibernate.SessionException;
010:        import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
011:        import org.hibernate.engine.NamedQueryDefinition;
012:        import org.hibernate.engine.NamedSQLQueryDefinition;
013:        import org.hibernate.engine.SessionImplementor;
014:        import org.hibernate.engine.QueryParameters;
015:        import org.hibernate.engine.SessionFactoryImplementor;
016:        import org.hibernate.engine.query.HQLQueryPlan;
017:        import org.hibernate.engine.query.NativeSQLQueryPlan;
018:
019:        import java.util.List;
020:
021:        /**
022:         * Functionality common to stateless and stateful sessions
023:         * 
024:         * @author Gavin King
025:         */
026:        public abstract class AbstractSessionImpl implements  SessionImplementor {
027:
028:            protected transient SessionFactoryImpl factory;
029:            private boolean closed = false;
030:
031:            protected AbstractSessionImpl(SessionFactoryImpl factory) {
032:                this .factory = factory;
033:            }
034:
035:            public SessionFactoryImplementor getFactory() {
036:                return factory;
037:            }
038:
039:            public boolean isClosed() {
040:                return closed;
041:            }
042:
043:            protected void setClosed() {
044:                closed = true;
045:            }
046:
047:            protected void errorIfClosed() {
048:                if (closed) {
049:                    throw new SessionException("Session is closed!");
050:                }
051:            }
052:
053:            public Query getNamedQuery(String queryName)
054:                    throws MappingException {
055:                errorIfClosed();
056:                NamedQueryDefinition nqd = factory.getNamedQuery(queryName);
057:                final Query query;
058:                if (nqd != null) {
059:                    String queryString = nqd.getQueryString();
060:                    query = new QueryImpl(queryString, nqd.getFlushMode(),
061:                            this , getHQLQueryPlan(queryString, false)
062:                                    .getParameterMetadata());
063:                    query.setComment("named HQL query " + queryName);
064:                } else {
065:                    NamedSQLQueryDefinition nsqlqd = factory
066:                            .getNamedSQLQuery(queryName);
067:                    if (nsqlqd == null) {
068:                        throw new MappingException("Named query not known: "
069:                                + queryName);
070:                    }
071:                    query = new SQLQueryImpl(nsqlqd, this , factory
072:                            .getQueryPlanCache().getSQLParameterMetadata(
073:                                    nsqlqd.getQueryString()));
074:                    query.setComment("named native SQL query " + queryName);
075:                    nqd = nsqlqd;
076:                }
077:                initQuery(query, nqd);
078:                return query;
079:            }
080:
081:            public Query getNamedSQLQuery(String queryName)
082:                    throws MappingException {
083:                errorIfClosed();
084:                NamedSQLQueryDefinition nsqlqd = factory
085:                        .getNamedSQLQuery(queryName);
086:                if (nsqlqd == null) {
087:                    throw new MappingException("Named SQL query not known: "
088:                            + queryName);
089:                }
090:                Query query = new SQLQueryImpl(nsqlqd, this , factory
091:                        .getQueryPlanCache().getSQLParameterMetadata(
092:                                nsqlqd.getQueryString()));
093:                query.setComment("named native SQL query " + queryName);
094:                initQuery(query, nsqlqd);
095:                return query;
096:            }
097:
098:            private void initQuery(Query query, NamedQueryDefinition nqd) {
099:                query.setCacheable(nqd.isCacheable());
100:                query.setCacheRegion(nqd.getCacheRegion());
101:                if (nqd.getTimeout() != null)
102:                    query.setTimeout(nqd.getTimeout().intValue());
103:                if (nqd.getFetchSize() != null)
104:                    query.setFetchSize(nqd.getFetchSize().intValue());
105:                if (nqd.getCacheMode() != null)
106:                    query.setCacheMode(nqd.getCacheMode());
107:                query.setReadOnly(nqd.isReadOnly());
108:                if (nqd.getComment() != null)
109:                    query.setComment(nqd.getComment());
110:            }
111:
112:            public Query createQuery(String queryString) {
113:                errorIfClosed();
114:                QueryImpl query = new QueryImpl(queryString, this ,
115:                        getHQLQueryPlan(queryString, false)
116:                                .getParameterMetadata());
117:                query.setComment(queryString);
118:                return query;
119:            }
120:
121:            public SQLQuery createSQLQuery(String sql) {
122:                errorIfClosed();
123:                SQLQueryImpl query = new SQLQueryImpl(sql, this , factory
124:                        .getQueryPlanCache().getSQLParameterMetadata(sql));
125:                query.setComment("dynamic native SQL query");
126:                return query;
127:            }
128:
129:            protected HQLQueryPlan getHQLQueryPlan(String query, boolean shallow)
130:                    throws HibernateException {
131:                return factory.getQueryPlanCache().getHQLQueryPlan(query,
132:                        shallow, getEnabledFilters());
133:            }
134:
135:            protected NativeSQLQueryPlan getNativeSQLQueryPlan(
136:                    NativeSQLQuerySpecification spec) throws HibernateException {
137:                return factory.getQueryPlanCache().getNativeSQLQueryPlan(spec);
138:            }
139:
140:            public List list(NativeSQLQuerySpecification spec,
141:                    QueryParameters queryParameters) throws HibernateException {
142:                return listCustomQuery(getNativeSQLQueryPlan(spec)
143:                        .getCustomQuery(), queryParameters);
144:            }
145:
146:            public ScrollableResults scroll(NativeSQLQuerySpecification spec,
147:                    QueryParameters queryParameters) throws HibernateException {
148:                return scrollCustomQuery(getNativeSQLQueryPlan(spec)
149:                        .getCustomQuery(), queryParameters);
150:            }
151:
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.