Object-Relational Mapping (or ORM), is a programming technique that links databases to object-oriented language concepts, creating (in effect) a “virtual object database.” There are both free and commercial packages available that perform object-relational mapping, although some programmers opt to code their own object-relational mapping for their systems.
In object-oriented programming, programming objects represent real-world objects. To illustrate, consider the example of an address book, which contains listings of people along with zero or more phone numbers and zero or more addresses. In object-oriented terms this would be represented by a “person object” with “slots” (fields, members, instance variables etc.) to hold the data that make up this listing: the person’s name, a list (or array) of phone numbers, and a list of addresses.
The crux of the problem is in translating those objects to forms which can be stored in files or databases, and which can later be retrieved easily while preserving the properties of the objects and their relationships; these objects can then be said to be persistent.
Object-Relational systems attempt to solve this problem by providing libraries of classes which are able to do this mapping automatically. Given a list of tables in the database, and objects in the program, they will automatically map requests from one to the other. Asking a person object for its phone numbers will result in the proper query being created and sent, and the results being “magically” translated directly into phone number objects inside the program.
From a programmer’s perspective, the system looks like a persistent object store. One can create objects and work with them as one would normally, and they automatically end up in the relational database.
A number of ORM frameworks have been created for ColdFusion:
Reactor, created by Doug Hughes of Alagad fame, is a very simple API for ColdFusion which generates and instantiates database abstraction CFCs on the fly as needed.
Active Record Factory (Arf!) is a Rails-style ActiveRecord implementation in ColdFusion.
Below is a list of the basics that Arf! provides:
- JDBC metadata based reflection: not database specific
- Creates ActiveRecord API‘d instances out of CFCs that extend a base ActiveRecord component
- Implements hasMany() and belongsTo() methods for establishing Record properties that point to other tables
- Allows for overloading any of the automagically generated methods to add custom business logic
- Automagic methods on Records include GetInstance(), Create(), Read(), Update(), Delete(), Save() [smart create/update], List(orderBy, whereClause), Validate() [does type and length checking], and SetNNN()/GetNNN() methods for each DB column
Developed by Nicholas Tunney, objectBreeze is an ORM tool that allows you to interact with your data persistence layer and easily model objects within your ColdFusion applications. With no setup, objectBreeze will instantly create objects directly from your database schema. objectBreeze requires that your table has -a- primary key defined. Currently, objectBreeze works with Microsoft SQL, Oracle, MySQL and PostgreSQL, but other versions are on the way.
Batch generation of your data layer objects in minutes.
Transfer was built out of a need to speed up the development process that is normally slowed down by the development of Business Objects and Data Access Objects.
Transfer does this through a series of methods, including SQL generation and CFML code generation, that all occur during the run-time process.
All this is configured through a XML file, that maps your object generation back to the tables and columns in your database.