Master's Thesis
April 2009
Abstract
This thesis deals with design and implementation of a library providing object-relational mapping services for programs written in C++. Emphasis is put on its transparency and ease of its use. To achieve these goals the library uses GCCXML, a XML output extension to GCC. GCCXML helps the library to get description of the class model used in the user application and to simulate the reflection.
For the mapping purposes, new object-relational database features are discussed and a new mapping type is proposed.
Implementation of the library is based on three related projects - the POLiTe, POLiTe 2 and IOPC libraries. The proposed and implemented library unifies them into one solid, flexible and extensible platform. Thanks to its modular architecture, the resulting library can be used in several configurations providing subsets of implemented services - database access, reflection and object-relational mapping.
Table of Contents
- 1. Introduction
- 2. Persistence layer requirements
- 3. Evolution of the IOPC 2 library
- 4. Basic concepts of the IOPC 2 library
- 5. Architecture of the IOPC 2 library
- 6. Conclusion
- References
- A. User's guide
- B. Sample schema SQL scripts
- C. Metadata overview
- D. DVD content
List of Figures
- 1.1. IOPC 2 evolution
- 2.1. Example class hierarchy
- 2.2. Vertical mapping tables
- 2.3. Horizontal mapping tables
- 2.4. Filtered mapping tables
- 2.5. Combined mapping tables
- 2.6. Proposed architecture of the O/R mapping library
- 3.1. Architecture of the POLiTe library
- 3.2. POLiTe persistent object states
- 3.3. POLiTe references
- 3.4. Architecture of the POLiTe 2 library
- 3.5. Caches in the POLiTe 2 library
- 3.6. States of the POLiTe 2 objects
- 3.7. Dereferencing DbPtr in POLiTe 2
- 3.8. The IOPC library workflow
- 3.9. POLiTe library components used in IOPC LIB
- 3.10. Structure of the IOPC LIB
- 4.1. Reflection using the GCCXML
- 4.2. IOPC 2 base classes
- 4.3. SQL schema generated from classes using combined mapping
- 4.4. Top-level part of the object-relational mapping algorithm
- 4.5. Description of the Insert_Row method. Not used for ADT mapping.
- 4.6. Inserting objects using filtered mapping
- 4.7. Iterative loading algorithm
- 5.1. Overview of the IOPC 2 architecture
- 5.2. Basic classes of the database layer
- 5.3. Using the decorator pattern
- 5.4. Oracle 10g database driver extensions and driver features
- 5.5. The iopcmeta classes
- 5.6. Structure of the enhanced data type classes
- 5.7. Classes involved in the database mapping process
- 5.8. Classes manipulating with persistent objects
- 5.9. The bePersistent operation
- 5.10. Database pointer and cache pointer interaction
- 5.11. Interaction with the O/R mapping services
- 5.12. Basic classes of the cache layer. VoidCache architecture.
- 5.13. Extended interface of the cache layer.
- 5.14. The Query classes
List of Examples
- 2.1. Using object types in Oracle
- 2.2. Accessing objects in Oracle
- 2.3. Nested tables in Oracle
- 2.4. References in Oracle
- 2.5. A polymorphic query using object-relational features of the Oracle database.
- 3.1. Definition of a class in the POLiTe library
- 3.2. Associations in the POLiTe library
- 3.3. Persistent object manipulation
- 3.4. Queries in the POLiTe library
- 3.5. Persistent object manipulation in the POLiTe 2 library
- 3.6. Executing queries in the POLiTe 2 library
- 3.7. Definition of persistent classes in IOPC
- 3.8. XML metamodel description file
- 4.1. Basic persistent class definition in IOPC 2
- 4.2. GCCXML output
- 4.3. IOPC SP output
- 4.4. DatabaseObject usage
- 4.5. SQL schema generated for DatabaseObject subclasses.
- 4.6. SQL schema generated for OidObject subclasses.
- 4.7. Using the ADT mapping.
- 4.8. SQL schema from classes that use ADT mapping.
- 4.9. Loading objects using ADTs from an Oracle database
- 5.1. Connecting to an Oracle database in IOPC 2
- 5.2. Type traits
- 5.3. Using the reflection interface
- 5.4. Enhanced datatype usage
- 5.5. Java annotations and C# attributes
- 5.6. Example usage of metadata in the IOPC 2 library
- 5.7. Friend type description declaration
- 5.8. Using the ScriptsGenerator to create required database schema.
- 5.9. Using the bePersistent method
- 5.10. Example query in IOPC 2