Source Code Cross Referenced for RelationalDatabaseStorageManager.java in  » Database-ORM » MMBase » org » mmbase » storage » implementation » database » 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 » MMBase » org.mmbase.storage.implementation.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.storage.implementation.database;
011:
012:        import org.mmbase.module.core.*;
013:        import org.mmbase.storage.StorageException;
014:        import org.mmbase.core.CoreField;
015:        import org.mmbase.bridge.Field;
016:        import org.mmbase.util.logging.Logger;
017:        import org.mmbase.util.logging.Logging;
018:
019:        /**
020:         * A JDBC implementation of a storage manager for relational databases.
021:         * @javadoc
022:         *
023:         * @author Pierre van Rooden
024:         * @since MMBase-1.7
025:         * @version $Id: RelationalDatabaseStorageManager.java,v 1.12 2008/02/03 17:33:57 nklasens Exp $
026:         */
027:        public class RelationalDatabaseStorageManager extends
028:                DatabaseStorageManager {
029:
030:            private static final Logger log = Logging
031:                    .getLoggerInstance(RelationalDatabaseStorageManager.class);
032:
033:            public RelationalDatabaseStorageManager() {
034:            }
035:
036:            // javadoc is inherited
037:            public double getVersion() {
038:                return 1.0;
039:            }
040:
041:            protected boolean tablesInheritFields() {
042:                return false;
043:            }
044:
045:            /**
046:             * Adds a node to the passed builder and all its parent builders.
047:             * @param node The node to insert. The node already needs to have a (new) number assigned
048:             * @param builder the builder to store the node
049:             * @throws StorageException if an error occurred during creation
050:             */
051:            public void create(final MMObjectNode node,
052:                    final MMObjectBuilder builder) throws StorageException {
053:                boolean localTransaction = !inTransaction;
054:                if (localTransaction) {
055:                    beginTransaction();
056:                }
057:                try {
058:                    // insert in parent tables (from parents to childs) (especially because foreign keys on object's number may exist)
059:                    for (MMObjectBuilder b : builder.getAncestors()) {
060:                        for (CoreField f : b.getFields()) {
061:                            if (f.getType() == Field.TYPE_BINARY) {
062:                                // if the value is an inputstream at the moment, convert it to a byte-array, because it must be stored again..
063:                                node.storeValue(f.getName(),
064:                                        org.mmbase.util.Casting.toByte(node
065:                                                .retrieveValue(f.getName())));
066:                            }
067:                        }
068:                        super .create(node, b);
069:                    }
070:                    super .create(node, builder);
071:                    if (localTransaction)
072:                        commit();
073:                } catch (StorageException se) {
074:                    if (localTransaction && inTransaction)
075:                        rollback();
076:                    throw se;
077:                }
078:            }
079:
080:            /**
081:             * Changes a node in the passed builder and all its parent builders
082:             * @param node The node to change
083:             * @param builder the builder to change the node in
084:             * @throws StorageException if an error occurred during change
085:             */
086:            public void change(MMObjectNode node, MMObjectBuilder builder)
087:                    throws StorageException {
088:                boolean localTransaction = !inTransaction;
089:                if (localTransaction) {
090:                    beginTransaction();
091:                }
092:                try {
093:                    do {
094:                        super .change(node, builder);
095:                        builder = builder.getParentBuilder();
096:                    } while (builder != null);
097:                    if (localTransaction)
098:                        commit();
099:                } catch (StorageException se) {
100:                    if (localTransaction && inTransaction)
101:                        rollback();
102:                    throw se;
103:                }
104:            }
105:
106:            /**
107:             * Deletes a node in the passed builder and all its parent builders.
108:             * @param node The node to delete
109:             * @param builder the builder to delete the node in
110:             * @throws StorageException if an error occurred during delete
111:             */
112:            public void delete(MMObjectNode node, MMObjectBuilder builder)
113:                    throws StorageException {
114:                boolean localTransaction = !inTransaction;
115:                if (localTransaction) {
116:                    beginTransaction();
117:                }
118:
119:                try {
120:                    do {
121:                        super .delete(node, builder);
122:                        builder = builder.getParentBuilder();
123:                    } while (builder != null);
124:                    if (localTransaction)
125:                        commit();
126:                } catch (StorageException se) {
127:                    if (localTransaction && inTransaction)
128:                        rollback();
129:                    throw se;
130:                }
131:            }
132:
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.