
602
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
ORM settings
The following are the data source-specific ORM settings for which you can specify string or struct values in the
Application.cfc:
•
schema
•
catalog
•
dialect
•
dbcreate
•
sqlscript
For multiple data sources, a struct can be specified with data source name as the key and the appropriate setting as the
value. If a string value is specified, it applies to the default data source of ORM.
Example 1
<cfset this.ormsettings.dbcreate={artgallery="dropcreate", bookclub="none"}>
Example 2
<cfset this.ormsettings.dbcreate="dropcreate">
If multiple data sources are used for ORM, these settings apply to the default ORM data source.
Mapping using Hibernate mapping files
In multiple data source scenarios, the data source information must be provided in the CFC (and not in .hbmxml file).
Also, all CFCs used in one .hbmxml file must have the same data source.
Example
The following example illustrates two different entities using two different data sources. In this example, art.cfc and
artist.cfc are related and therefore use the same data source.
art.cfc
<cfcomponent persistent="true" table="art" datasource="cfartgallery">
<cfproperty name="ArtID" fieldtype="id" generator="native">
<cfproperty name="ArtName">
<cfproperty name="IsSold">
</cfcomponent>
artists.cfc
<cfcomponent persistent="true" table="artists" datasource="cfartgallery">
<cfproperty name="ArtistID" fieldtype="id">
<cfproperty name="FirstName">
<cfproperty name="LastName">
<cfproperty name="art" fieldtype="one-to-many" cfc="art" fkcolumn="ArtistID">
</cfcomponent>
authors.cfc
<cfcomponent persistent="true" table=authors datasource="cfbookclub">
<cfproperty name="AuthorID" fieldtype="id">
<cfproperty name="LastName">
<cfproperty name="FirstName">
</cfcomponent>
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...