Support For Multiple Data Sources For Orm - Adobe 38043740 - ColdFusion Standard - Mac Development Manual

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
ColdFusion ORM

Support for multiple data sources for ORM

Note: This feature applies only if you have installed ColdFusion 9 Update 1.
Introduction
You can use multiple data sources for ORM in ColdFusion applications. A multiple data source setup is useful in
scenarios where your application has multiple modules that interact with each other.
Hibernate inherently supports single data source for a Hibernate configuration. To support multiple data sources,
ColdFusion builds and manages multiple Hibernate configurations and SessionFactory objects, one for each data
source in the application.
Usage scenario
Consider an application with the following three modules:
• HR
• Finance
• Sales
Assume that all these modules have their own databases (and therefore separate data sources). But at the application-
level, all the three modules have to interact with each other. A single data source makes it impossible to build the entire
application using ORM. Building three separate applications is not advisable as the interaction between the
applications is possible only using web services.
If you use a multiple data source setup for ORM, all the three modules can be built in ORM. They can be part of the
same application and the modules can interact with each other.
Configuring the application to use multiple data sources
Configure Persistent CFCs with the attribute
attribute data source on the CFC using the tag
CFC definition. If you do not specify a data source, the default data source is used for that CFC.
Since a Hibernate configuration uses a single data source, all related CFCs (using ORM relationships) must have the
same data source.
Example
Art.cfc
<cfcomponent persistent="true" datasource="artgallery" table="Art">
...
</cfcomponent>
Author.cfc
<cfcomponent persistent="true" datasource="bookclub" table="author">
...
</cfcomponent>
pointing to the appropriate data source. You can specify the
datasource
or by specifying the annotation on Component in the
cfcomponent
Last updated 1/20/2012
601

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents