2008/11/18 Kevin Roche <[EMAIL PROTECTED]> > > Hi, > > I want to check how a table column that supports a relationship should be > defined. > > I have the following in my transfer XML file. > > <package name="Price"> > <object name="Price" table="Price"> > <id name="priceId" column="priceId" type="numeric"/> > <property name="packageId" column="packageId" type="numeric" > nullable="false" /> > <property name="featureId" column="featureId" type="numeric" > nullable="true" /> > <property name="periodCovered" column="periodCovered" > type="string" nullable="false" /> > <property name="billingRate" column="billingRate" > type="string" nullable="false" /> > <property name="startDate" column="startDate" type="date" > nullable="true" /> > <property name="endDate" column="endDate" type="date" > nullable="true" /> > <property name="price" column="price" type="numeric" > nullable="false" /> > <property name="isSpecialOffer" column="isSpecialOffer" > type="boolean" nullable="false" /> > <property name="isActive" column="isActive" type="boolean" > nullable="false" /> > </object> > </package> > > In fact packageId and FeatureId are both foreign key fields so I propose to > add two many to one entries: > > <package name="Price"> > <object name="Price" table="Price"> > <id name="priceId" column="priceId" type="numeric"/> > <property name="packageId" column="packageId" type="numeric" > nullable="false" /> > <property name="featureId" column="featureId" type="numeric" > nullable="true" /> > <property name="periodCovered" column="periodCovered" > type="string" nullable="false" /> > <property name="billingRate" column="billingRate" > type="string" nullable="false" /> > <property name="startDate" column="startDate" type="date" > nullable="true" /> > <property name="endDate" column="endDate" type="date" > nullable="true" /> > <property name="price" column="price" type="numeric" > nullable="false" /> > <property name="isSpecialOffer" column="isSpecialOffer" > type="boolean" nullable="false" /> > <property name="isActive" column="isActive" type="boolean" > nullable="false" /> > > > <manytoone name="Feature"> > <link to="Feature.Feature" column="featureId" /> > </manytoone> > <manytoone name="Package"> > <link to="Package.Package" column="packageId" /> > </manytoone> > > </object> > </package> > > Should the property tags be removed at the same time? If so how do I > specify > that the featureId is optional since there seems not to be an equivalent to > nullable="true"? >
Yes you need to remove the property for your foreign key. You don't need to specify that the column is nullable. You simply don't add a child object for feature and/or package. When you pull the saved record from cache/database you will need to check to make sure that your price object hasFeature or hasPackage before you do a getFeature or getPackage, otherwise it will throw an error. http://docs.transfer-orm.com/wiki/Generated_Methods.cfm#ManyToOne_Element <<< A page that's open constantly for me - I really need to sort out neat printout cheat sheet... Stephen --~--~---------~--~----~------------~-------~--~----~ Before posting questions to the group please read: http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer You received this message because you are subscribed to the Google Groups "transfer-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/transfer-dev?hl=en -~----------~----~----~----~------~----~------~--~---
