A PersistenceLayer connecting objects in an object-oriented system to data stored in a relational database. Most commonly, an SQL database is used (though strictly speaking, SQL does not implement the RelationalModel -- see SqlFlaws and RelationalLanguage for more details). Using an ObjectRelationalMapping (ORM) allows one to cleanly apply object-oriented design, analysis, and programming techniques while hiding the specifics of dealing with the relational system. There are commercial and OpenSource ORMs that comply to the ODMG and JDO standard APIs for object persistence. Programming against such a mapping is not different from programming against an ObjectOrientedDatabase. Using such a ORM may be a good compromise between OO designers/architects insisting on pure object orientation without any data knowledge, and DBAs/managers emphasizing the shortcomings of OODBMSs. -- ThomasMahler ---- A PrevalenceLayer is another option to forget database hassle. ---- See also the following: * DatabaseImpedanceMismatch, ObjectRelationalImpedanceMismatch **Discussions of incompatibilities between the design of databases and application host languages ** example: set operations and null values are not supported in many host languages * LetsUseAnObjectOrientedDatabase ** Discussion of business's choice of RelationalDatabases instead of Object Databases * CrossingChasms ** Pattern Language for mapping objects to RelationalDatabase tables * DataTransferObjectInjection ** A (common security issue when combined with RemoteObjectServices * ScottAmbler ** Papers on mapping objects to RelationalDatabase tables *** http://www.ambysoft.com/essays/mappingObjects.html * Article on persistence layer architecture ** including design principles and anti-patterns *** http://www.sce-tech.com/architecture/persistence_layers.html * RelationalDatabaseAccessLayer ** Mapping RelationalDatabase to procedural code * Another review of many different tools and issues ** organized by the structure of the API (CMP, JDO, Generalized...). *** http://www.SimpleORM.org/ORMTools.html * A full featured Object Relational Mapping (ORM) toolset ** helps realizing UML design to database implementation *** http://www.visual-paradigm.com/dbva.php ---- Implementations: * Separate these by language ** Java Skyline Database *** http://www.javaskyline.com/database.html Lists over 50 Object-SQL Mapping Tools, * The scope of each tool * A list of other Java database resources and * A list of other object-SQL tool lists, including the: * ObjectRelationalMappingExperiences ** using these products (or your own) could also offer some insight * ObjectRelationalToolComparison ** contains an extensive comparison of popular O/R tools * ObjectRelationalBridge (OJB) ** OpenSource project providing ODMG and JDO compliant APIs *** http://db.apache.org/ojb/ * FireStorm/DAO *** generates DataAccessObject''''''s (DAOs) directly from database schemas * SQL Orm ** Simple low level SQL-based ORM with easy refactoring possibilities *** http://sqlorm.sourceforge.net/database_refactoring_made_easy.html * TopLink ** ObjectRelationalMapping product for Java on web servers. ** (SmalltalkLanguage too? * EnterpriseObjectsFramework ** Abbreviated: EOF - The framework used in WebObjects, from AppleComputer (now pure Java in WebObjectsFive - Documentation can be found at *** http://developer.apple.com/techpubs/webobjects/webobjects.html * SimpleOrm ** A very Simple, light weight ORM. No generation, byte code post processing or even an XML file to configure. But fast and effective. *** http://www.SimpleORM.org * Persistence technology ** including 'active' relationships and path expressions. Originally conceived from the EOF vision. *** http://www.sce-tech.com/research/persistence.html * CastorFramework ** The OpenSource framework which uses CastorJDO to convert java objects to SQL or XML data * AtgRepositoryFramework ** The framework used in AtgDynamo, from Art Technology Group. ** Handles Java, XML, LDAP, SQL, sub classes of items (i.e. you can have a RepositoryItem representing Person and subclass that with more information to make a Manager) ** instance inheritance (doing sort of the same thing, but dynamically) ** and property derivation (get the name from the subclass if it exists, otherwise get it from the superclass) * CayenneFramework ** The OpenSource framework and GUI tool that provides functionality similar to EnterpriseObjectsFramework * JaxorFramework ** Generates persistence layer as well as objects based upon xml metadata * JdoGenie ** Fast JDO implementation for JDBC databases * ProductivityEnvironmentForJava **JDO implementation for JDBC RelationalDatabase systems * ClassDbi **OpenSource Perl object to database mapping layer * HiberNate ** OpenSource Java *** http://hibernate.sourceforge.net * ActiveRecord **OpenSource Ruby framework *** http://activerecord.rubyonrails.org/show/HomePage * SQLObject **OpenSource Python framework *** http://sqlobject.org/ * EZPDO **OpenSource ORM Framework for PHP5 *** http://www.ezpdo.net * Picasso **OpenSource .NET *** http://picasso.codeplex.com * Gentle.NET ** OpenSource framework for .NET written in C# based on ScottAmbler's papers. Supports PostgreSQL, MySQL, MS SQL Server and SQLite. *** http://freshmeat.net/projects/gentle ** for a tutorial *** http://www.mertner.com/projects/gentle for a tutorial). * Genome ** O/R Mapper for .NET and SQL Server/Oracle (more information and eval download: *** http://www.genom-e.com); free community license * AtomsFramework ** OpenSource framework for VB6 and .NET ***http://jcframework.sourceforge.net * Object Relational MappingSoftware ** WikiPedia list *** http://en.wikipedia.org/wiki/Comparison_of_object-relational_mapping_software ---- ChrisDate and HughDarwen have much to say on this in ''TheThirdManifesto'', ISBN:0-201-70928-7 -- ChanningWalton ---- Any opinions on the JavaLayeredFrameworks approach outlined by ToddLauinger? Has anyone tried something like this? -- BernardFarrell ---- Class structures don't map properly to relations. This is due to what Date calls the FirstGreatBlunder, that is, mapping objects or classes to SQL tables, instead of to user-defined data types. ''If you map classes to user defined data types, this means that a cell can contain an object in the cell. This is TheMissedGreatBlunder because a struct or class is like a multi-cell row, and putting a multi-cell row inside a single cell, is a contradiction of relational! A row or struct contains multiple cells. Putting multiple cells inside a cell, is violating relational. Date and TheThirdManifesto hasn't got the final word on this; there are many unanswered questions and potential violations '''in their own proposed solution'''. If you map an object to a table, that object is accessible relationally; you can run queries on the tables (which were previously objects) and find data. If the object is located inside a cell on the other hand, that defeats the purpose of object relational mapping: the data is not accessible relationally, it's stuck inside the cell, like how an XML file can be placed inside a cell as a string.'' {Putting a multi-cell row inside a single cell is not a contradiction of the RelationalModel. Please read TheThirdManifesto or AnIntroductionToDatabaseSystems again! The only "rule" is that each attribute of a tuple or relation be of a given type aka domain. That type may be arbitrarily complex and may be '''any''' type, including tuple and relation types. Don't let your experience of SQL DBMS limits colour your understanding of the RelationalModel.} ''Consider a Cee struct which is very much like a class. Say we had a database that allowed Cee structs to be defined as types. Uh oh! You've just allowed a row (a struct is like a row) to be inserted inside a cell. Relational purism doesn't allow multiple cells inside a single cell. Relational doesn't allow sub tables inside cells.. the whole point of relational is that each cell is its own cell!'' ''Object relational mapping tries to split the object up into cells, instead of putting the entire object in a single cell. So who is violating relational? Date and Darwen, laughingly, are the ones that are violating relational, by thinking that database types can be classes too. As a compromise, one could violate relational and allow structs and classes to be stored inside cells, similar to how we can store xml files inside cells. The database doesn't stop you from storing xml files inside a cell since an XML file is just a string; but since that XML file contains multiple cells and values inside it, it's kind of a contradiction/violation of relational - you cannot access the XML file data relationally if the xml file is stored inside a cell.'' {Relation and tuple attribute types can be classes or XML DTDs; relation and tuple attribute values can be class instances or XML. This is not a violation of the RelationalModel.} Or is it relations that do not map properly to classes? ORMs enforce a ontological approach to object programming and I have the feeling that this is not a good thing. -- EmmanuelDeloget ---- A sequence, as might be implemented by linked list, must be represented either by precedence (as in CREATE TABLE sequence (father INTEGER, child INTEGER);) or by a specific type... unfortunately SQL doesn't support user-defined types. Also one can have a "Sequence''''''Order" attribute that is a real number or integer. But linked lists are not an OO concept. Often times a time-stamp or auto-generated ID's can be used if it is to capture a temporal sequence. ----- See also: ObjectRelationalMappingCostsTimeAndMoney ----- I'm inclined to think current implementations of ORMs are anti-patterns since they are little languages and errors in the little languages aren't syntactically bound to compilation so you have to constantly go back and forth in the runtime to figure out what's wrong in your JPQL syntax for example. I agree with consolidating database access and avoiding scattered sql everywhere but I really don't like dealing with the mapping syntax. Mybatis is a better alternative although there are some similar issues there as well. ---- CategoryDataOrientation