
570
DEVELOPING
COLDFUSION 9 APPLICATIONS
ColdFusion ORM
Las
t
upda
te
d 8/5/2010
Table per subclass without discriminator
In this model, there are separate tables for each class in the hierarchy and these tables are joined by a primary key.
When the object is persisted, properties of the parent component are stored in the parent table and the remaining
properties are stored in the child table.
Table per subclass without discriminator
In the preceding figure, the tables are joined by join column
paymentId
. You can model the tables as follows:
Payment.cfc
<cfcomponent persistent="true" table="Payment">
<cfproperty name="paymentId">
<cfproperty name="amount">
</cfcomponent>
CreditCardpayment.cfc
<cfcomponent persistent="true" extends="Payment" table="CreditCardPayment"
joinColumn="paymentId"
>
<cfproperty name="cardNo">
<cfproperty name="cardType">
</cfcomponent>
CheckPayment.cfc
<cfcomponent persistent="true" extends="Payment" table="CheckPayment"
joinColumn="paymentId"
>
<cfproperty name="checkNo">
<cfproperty name="bankName">
<cfproperty name="city">
</cfcomponent>
When an object of type
CreditCardPayment
is persisted, the property
amount
is stored in the payment table and the
properties
cardNo
and
cardType
are stored in the CreditCardPayment table. The primary key of the
CreditCardPayment remains the same as the primary key of the Payment table.
Table per subclass with discriminator
This model is similar to the table per subclass without discriminator strategy except that there is a discriminator
column in the parent table. In addition, the child components has a
disciminatorValue
attribute in the
cfcomponent
tag.
The following example demonstrates the table per subclass with discriminator attribute:
Payment.cfc
Payment
PaymentID <<PK>>
Amount
CreditCardPayment
paymentID
cardNo
cardType
CheckPayment
paymentID
checkNo
bankName
city
Payment class extended by
CheckPayment class
CreditCardPayment class
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...