Adobe COLDFUSION 9 Manual page 559

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Escaping SQL keywords in table and column name
ColdFusion automatically escapes the table name or column name if it is an SQL keyword or if there is a space in it.
The list of SQL keywords are present in
ANSI SQL keywords and some database-specific keywords. You can modify this file to include any other SQL keyword
that is missing. In case you are adding SQL keyword for a database other than the ones specified in this file, you should
also add it to the 'ANSI' list so that ColdFusion can use it.
Define Relationships
Relationship is the most crucial aspect of ORM. In a relational database, relation between tables are defined using
foreign key. However, in case of objects, relation between two objects is defined using association where one object has
a reference to another. ORM defines how the object relation is mapped to the database relation.
In this topic, relation and association would be used interchangeably.
Before you learn how to define the mapping for relation, it is important to understand few key concepts:
• Source object: Object having the reference to the related object is termed as source of the relationship.
• Target object: Object being referred or associated is termed as target of the relationship.
• Direction and Navigability: In relational database, the relationship is always unidirectional, which implies that you
can navigate from one table to another but not back to the same table. However, object model can be either
unidirectional or bidirectional. A unidirectional association means that source has the reference to the target but the
target does not know about the source. A bidirectional association means that both the objects have reference to each
other and you can navigate from either object to another. In other words, source has a reference to the target and
target also has a reference to the source. This also means that both the objects are source and target at the same time.
To set the association between objects, you need to set the references appropriately. For example, in case of Person-
Address relation, where one person as one address, you need to associate Address to person as:
person.setAddress(address);
At this point, person object knows about the Address object but the address object does not know the person object.
So, this is a unidirectional relation between Person-Address. To make this bidirectional, you need to associate
Person to Address as:
address.setPerson(person);
• Multiplicity: This defines how many target entities can a particular source have and how many source entities can
a particular target have. Consider the example of artwork and artist, where an artist has many artwork pieces. In an
object model, an artwork has reference to one artist and an artist has reference to many pieces of artwork. So, for
artwork and artist the multiplicity is many-to-one and for artist and artwork, it is one-to-many. The other two type
of multiplicities are one-to-one and many-to-many.
In this topic, multiplicity would be referred to as the type of relationship.
To indicate that a property defines the relationship between two persistent components, as a result of relationship in
the database table, specify the
• one-to-one
• one-to-many
• many-to-one
• many-to-many
<CF_HOME>/lib/sqlkeywords.properties
in the
fieldtype
cfproperty
Last updated 8/5/2010
file. This file contains standard
tag to one of the following:
554

Advertisement

Table of Contents
loading

Table of Contents