Source Code Cross Referenced for DbTransactionMode.java in  » Development » jodd » jodd » db » 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 » Development » jodd » jodd.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2003-2007, Jodd Team (jodd.sf.net). All Rights Reserved.
002:
003:        package jodd.db;
004:
005:        import jodd.util.ObjectUtil;
006:        import jodd.util.HashCodeUtil;
007:        import jodd.jtx.JtxTransactionMode;
008:
009:        import java.sql.Connection;
010:
011:        /**
012:         * Native SQL transaction mode for {@link DbSession} transactions.
013:         */
014:        public class DbTransactionMode {
015:
016:            public DbTransactionMode() {
017:                this .isolation = ISOLATION_DEFAULT;
018:                this .readOnlyMode = READ_ONLY;
019:            }
020:
021:            /**
022:             * Created db transaction mode from general {@link jodd.jtx.JtxTransactionMode}.
023:             */
024:            public DbTransactionMode(JtxTransactionMode txMode) {
025:                switch (txMode.getIsolation()) {
026:                case JtxTransactionMode.ISOLATION_DEFAULT:
027:                    isolation = ISOLATION_DEFAULT;
028:                    break;
029:                case JtxTransactionMode.ISOLATION_NONE:
030:                    isolation = ISOLATION_NONE;
031:                    break;
032:                case JtxTransactionMode.ISOLATION_READ_COMMITTED:
033:                    isolation = ISOLATION_READ_COMMITTED;
034:                    break;
035:                case JtxTransactionMode.ISOLATION_READ_UNCOMMITTED:
036:                    isolation = ISOLATION_READ_UNCOMMITTED;
037:                    break;
038:                case JtxTransactionMode.ISOLATION_REPEATABLE_READ:
039:                    isolation = ISOLATION_REPEATABLE_READ;
040:                    break;
041:                case JtxTransactionMode.ISOLATION_SERIALIZABLE:
042:                    isolation = ISOLATION_SERIALIZABLE;
043:                    break;
044:                default:
045:                    throw new DbSqlException(
046:                            "Unknown transaction isolation mode '"
047:                                    + txMode.getIsolation() + "'.");
048:                }
049:
050:                readOnlyMode = txMode.isReadOnly();
051:            }
052:
053:            // ---------------------------------------------------------------- isolation
054:
055:            /**
056:             * Default isolation.
057:             */
058:            public static final int ISOLATION_DEFAULT = -1;
059:            /**
060:             *  @see Connection#TRANSACTION_NONE
061:             */
062:            public static final int ISOLATION_NONE = Connection.TRANSACTION_NONE;
063:            /**
064:             *  @see Connection#TRANSACTION_READ_UNCOMMITTED
065:             */
066:            public static final int ISOLATION_READ_UNCOMMITTED = Connection.TRANSACTION_READ_UNCOMMITTED;
067:            /**
068:             *  @see Connection#TRANSACTION_READ_COMMITTED
069:             */
070:            public static final int ISOLATION_READ_COMMITTED = Connection.TRANSACTION_READ_COMMITTED;
071:            /**
072:             *  @see Connection#TRANSACTION_REPEATABLE_READ
073:             */
074:            public static final int ISOLATION_REPEATABLE_READ = Connection.TRANSACTION_REPEATABLE_READ;
075:            /**
076:             *  @see Connection#TRANSACTION_SERIALIZABLE
077:             */
078:            public static final int ISOLATION_SERIALIZABLE = Connection.TRANSACTION_SERIALIZABLE;
079:
080:            private int isolation;
081:
082:            public int getIsolation() {
083:                return isolation;
084:            }
085:
086:            public DbTransactionMode setIsolation(int isolation) {
087:                this .isolation = isolation;
088:                return this ;
089:            }
090:
091:            public DbTransactionMode isolationNone() {
092:                this .isolation = ISOLATION_NONE;
093:                return this ;
094:            }
095:
096:            public DbTransactionMode isolationReadUncommitted() {
097:                this .isolation = ISOLATION_READ_UNCOMMITTED;
098:                return this ;
099:            }
100:
101:            public DbTransactionMode isolationReadCommited() {
102:                this .isolation = ISOLATION_READ_COMMITTED;
103:                return this ;
104:            }
105:
106:            public DbTransactionMode isolationRepeatableRead() {
107:                this .isolation = ISOLATION_REPEATABLE_READ;
108:                return this ;
109:            }
110:
111:            public DbTransactionMode isolationSerializable() {
112:                this .isolation = ISOLATION_SERIALIZABLE;
113:                return this ;
114:            }
115:
116:            // ---------------------------------------------------------------- read-only
117:
118:            public static final boolean READ_ONLY = true;
119:            public static final boolean READ_WRITE = false;
120:
121:            private boolean readOnlyMode = READ_ONLY;
122:
123:            public boolean isReadOnly() {
124:                return readOnlyMode;
125:            }
126:
127:            public DbTransactionMode setReadOnly(boolean readOnly) {
128:                this .readOnlyMode = readOnly;
129:                return this ;
130:            }
131:
132:            // ---------------------------------------------------------------- equals & hashCode
133:
134:            @Override
135:            public boolean equals(Object object) {
136:                if (this  == object) {
137:                    return true;
138:                }
139:                if (ObjectUtil.equalsType(object, this ) == false) {
140:                    return false;
141:                }
142:                final DbTransactionMode mode = (DbTransactionMode) object;
143:
144:                return (mode.getIsolation() == this .isolation)
145:                        && (mode.isReadOnly() == this .readOnlyMode);
146:            }
147:
148:            @Override
149:            public int hashCode() {
150:                int result = HashCodeUtil.SEED;
151:                result = HashCodeUtil.hash(result, this.readOnlyMode);
152:                result = HashCodeUtil.hash(result, this.isolation);
153:                return result;
154:            }
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.