Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 654

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Support for self joins
Database table can be related to itself through a foreign key. A typical example is an Employee table with a manager
relationship containing the employee id of the managers (who manage the employee).
The manager id refers to another row in the same table. This is an example of one-to-one self join.
There can be one-to-many self join and many-to-many self joins with an intermediate join table.
ColdFusion 9 Update 1 has self join support for all the relationships in the ActionScript ORM.
The following ActionScript class definition for customer entity illustrates how all the self-join relationships are
defined:
package
{
[Bindable]
[RemoteClass(alias="AIRIntegration.customer")]
[Entity]
public class Customer
{
[Id]
[GeneratedValue(strategy="INCREMENT",initialValue=5,incrementBy=2)]
public var cid:int;
public var name:String;
[OneToOne(cascadeType='ALL',fetchType="EAGER")]
[JoinColumn(name="add_id",referencedColumnName="aid")]
public var address:Address;
// Many-to-One self Join
[ManyToOne(targetEntity="onetoone::Customer",fetchType="EAGER")]
[JoinColumn(name="managerId",referencedColumnName="cid")]
public var manager:Customer;
// One-to-one Self Join
[OneToOne(targetEntity="onetoone::Customer",fetchType="EAGER")]
[JoinColumn(name="spouseId",referencedColumnName="cid",unique="true")]
public var spouse:Customer;
// Many-to-Many self Join
Last updated 1/20/2012
649

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents