Source Code Cross Referenced for ReplicationMode.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) 


01:        //$Id: ReplicationMode.java 5060 2004-12-24 03:11:05Z oneovthafew $
02:        package org.hibernate;
03:
04:        import java.io.Serializable;
05:        import java.util.HashMap;
06:        import java.util.Map;
07:
08:        import org.hibernate.type.VersionType;
09:
10:        /**
11:         * Represents a replication strategy.
12:         *
13:         * @see Session#replicate(Object, ReplicationMode)
14:         * @author Gavin King
15:         */
16:        public abstract class ReplicationMode implements  Serializable {
17:            private final String name;
18:            private static final Map INSTANCES = new HashMap();
19:
20:            public ReplicationMode(String name) {
21:                this .name = name;
22:            }
23:
24:            public String toString() {
25:                return name;
26:            }
27:
28:            public abstract boolean shouldOverwriteCurrentVersion(
29:                    Object entity, Object currentVersion, Object newVersion,
30:                    VersionType versionType);
31:
32:            /**
33:             * Throw an exception when a row already exists.
34:             */
35:            public static final ReplicationMode EXCEPTION = new ReplicationMode(
36:                    "EXCEPTION") {
37:                public boolean shouldOverwriteCurrentVersion(Object entity,
38:                        Object currentVersion, Object newVersion,
39:                        VersionType versionType) {
40:                    throw new AssertionFailure("should not be called");
41:                }
42:            };
43:            /**
44:             * Ignore replicated entities when a row already exists.
45:             */
46:            public static final ReplicationMode IGNORE = new ReplicationMode(
47:                    "IGNORE") {
48:                public boolean shouldOverwriteCurrentVersion(Object entity,
49:                        Object currentVersion, Object newVersion,
50:                        VersionType versionType) {
51:                    return false;
52:                }
53:            };
54:            /**
55:             * Overwrite existing rows when a row already exists.
56:             */
57:            public static final ReplicationMode OVERWRITE = new ReplicationMode(
58:                    "OVERWRITE") {
59:                public boolean shouldOverwriteCurrentVersion(Object entity,
60:                        Object currentVersion, Object newVersion,
61:                        VersionType versionType) {
62:                    return true;
63:                }
64:            };
65:            /**
66:             * When a row already exists, choose the latest version.
67:             */
68:            public static final ReplicationMode LATEST_VERSION = new ReplicationMode(
69:                    "LATEST_VERSION") {
70:                public boolean shouldOverwriteCurrentVersion(Object entity,
71:                        Object currentVersion, Object newVersion,
72:                        VersionType versionType) {
73:                    if (versionType == null)
74:                        return true; //always overwrite nonversioned data
75:                    return versionType.getComparator().compare(currentVersion,
76:                            newVersion) <= 0;
77:                }
78:            };
79:
80:            static {
81:                INSTANCES.put(LATEST_VERSION.name, LATEST_VERSION);
82:                INSTANCES.put(IGNORE.name, IGNORE);
83:                INSTANCES.put(OVERWRITE.name, OVERWRITE);
84:                INSTANCES.put(EXCEPTION.name, EXCEPTION);
85:            }
86:
87:            private Object readResolve() {
88:                return INSTANCES.get(name);
89:            }
90:
91:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.