Source Code Cross Referenced for LockMode.java in  » Database-ORM » hibernate » org » hibernate » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: LockMode.java 9581 2006-03-09 15:50:15Z epbernard $
002:        package org.hibernate;
003:
004:        import java.io.Serializable;
005:        import java.util.HashMap;
006:        import java.util.Map;
007:
008:        /**
009:         * Instances represent a lock mode for a row of a relational
010:         * database table. It is not intended that users spend much
011:         * time worrying about locking since Hibernate usually
012:         * obtains exactly the right lock level automatically.
013:         * Some "advanced" users may wish to explicitly specify lock
014:         * levels.
015:         *
016:         * @see Session#lock(Object,LockMode)
017:         * @author Gavin King
018:         */
019:        public final class LockMode implements  Serializable {
020:            private final int level;
021:            private final String name;
022:            private static final Map INSTANCES = new HashMap();
023:
024:            private LockMode(int level, String name) {
025:                this .level = level;
026:                this .name = name;
027:            }
028:
029:            public String toString() {
030:                return name;
031:            }
032:
033:            /**
034:             * Check if this lock mode is more restrictive than the given lock mode.
035:             *
036:             * @param mode LockMode to check
037:             * @return true if this lock mode is more restrictive than given lock mode
038:             */
039:            public boolean greaterThan(LockMode mode) {
040:                return level > mode.level;
041:            }
042:
043:            /**
044:             * Check if this lock mode is less restrictive than the given lock mode.
045:             *
046:             * @param mode LockMode to check
047:             * @return true if this lock mode is less restrictive than given lock mode
048:             */
049:            public boolean lessThan(LockMode mode) {
050:                return level < mode.level;
051:            }
052:
053:            /**
054:             * No lock required. If an object is requested with this lock
055:             * mode, a <tt>READ</tt> lock will be obtained if it is
056:             * necessary to actually read the state from the database,
057:             * rather than pull it from a cache.<br>
058:             * <br>
059:             * This is the "default" lock mode.
060:             */
061:            public static final LockMode NONE = new LockMode(0, "NONE");
062:            /**
063:             * A shared lock. Objects in this lock mode were read from
064:             * the database in the current transaction, rather than being
065:             * pulled from a cache.
066:             */
067:            public static final LockMode READ = new LockMode(5, "READ");
068:            /**
069:             * An upgrade lock. Objects loaded in this lock mode are
070:             * materialized using an SQL <tt>select ... for update</tt>.
071:             */
072:            public static final LockMode UPGRADE = new LockMode(10, "UPGRADE");
073:            /**
074:             * Attempt to obtain an upgrade lock, using an Oracle-style
075:             * <tt>select for update nowait</tt>. The semantics of
076:             * this lock mode, once obtained, are the same as
077:             * <tt>UPGRADE</tt>.
078:             */
079:            public static final LockMode UPGRADE_NOWAIT = new LockMode(10,
080:                    "UPGRADE_NOWAIT");
081:            /**
082:             * A <tt>WRITE</tt> lock is obtained when an object is updated
083:             * or inserted.   This lock mode is for internal use only and is
084:             * not a valid mode for <tt>load()</tt> or <tt>lock()</tt> (both
085:             * of which throw exceptions if WRITE is specified).
086:             */
087:            public static final LockMode WRITE = new LockMode(10, "WRITE");
088:
089:            /**
090:             * Similiar to {@link #UPGRADE} except that, for versioned entities,
091:             * it results in a forced version increment.
092:             */
093:            public static final LockMode FORCE = new LockMode(15, "FORCE");
094:
095:            static {
096:                INSTANCES.put(NONE.name, NONE);
097:                INSTANCES.put(READ.name, READ);
098:                INSTANCES.put(UPGRADE.name, UPGRADE);
099:                INSTANCES.put(UPGRADE_NOWAIT.name, UPGRADE_NOWAIT);
100:                INSTANCES.put(WRITE.name, WRITE);
101:                INSTANCES.put(FORCE.name, FORCE);
102:            }
103:
104:            private Object readResolve() {
105:                return parse(name);
106:            }
107:
108:            public static LockMode parse(String name) {
109:                return (LockMode) INSTANCES.get(name);
110:            }
111:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.