Can't believe I missed that :) Thanks Paul!

On Aug 4, 2:28 am, Paul Marcotte <[email protected]> wrote:
> Dan,
>
> If you remove the productId property from the review object definition, you
> should be golden.  Since that column forms the one to many relationship, you
> cannot also specify it as a property.
>
> Paul
>
>
>
>
>
> On Mon, Aug 3, 2009 at 9:30 PM, Dan Vega <[email protected]> wrote:
>
> > I have probably screwed something up here but I can not figure out why
> > i am getting this error. I have a product and each product can have
> > many reviews. I have  onetomany relationship defined like this.
>
> > <?xml version="1.0" encoding="UTF-8"?>
> > <transfer xsi:noNamespaceSchemaLocation="../../transfer/resouces/xsd/
> > transfer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
>
> >        <objectDefinitions>
>
> >                <object name="product" table="products"
> > decorator="unitedcommerce.model.Product">
> >                        <id name="id" type="numeric"/>
> >                        <property name="name" type="string"/>
> >                        <property name="author" type="string"/>
> >                        <property name="url" type="string"/>
> >                        <property name="price" type="numeric"/>
> >                        <property name="onSale" type="boolean"/>
> >                        <property name="screenshot" type="string"/>
> >                        <property name="thumbnail" type="string"/>
> >                        <property name="isFeatured" type="string"/>
>
> >                        <manytomany name="Category"
> > table="ProductCategories">
> >                                <link to="product" column="productId"/>
> >                                <link to="category" column="categoryId"/>
> >                                <collection type="array">
> >                                        <order property="name" order="asc"/>
> >                                </collection>
> >                        </manytomany>
>
> >                        <onetomany name="review">
> >                                <link to="review" column="productId"/>
> >                                <collection type="array">
> >                                        <order property="dateReviewed"
> > order="desc"/>
> >                                </collection>
> >                        </onetomany>
>
> >                </object>
>
> >                <object name="category" table="categories">
> >                        <id name="id" type="numeric"/>
> >                        <property name="name" type="string"/>
> >                        <property name="url" type="string"/>
> >                        <property name="active" type="boolean"/>
> >                </object>
>
> >                <object name="review" table="reviews">
> >                        <id name="id" type="numeric"/>
> >                        <property name="userId" type="numeric"/>
> >                        <property name="productId" type="numeric"/>
> >                        <property name="rating" type="numeric"/>
> >                        <property name="comments" type="string"/>
> >                        <property name="dateReviewed" type="date"/>
> >                </object>
>
> >                <object name="user" table="users"
> > decorator="unitedcommerce.model.User">
> >                        <id name="id" type="numeric"/>
> >                        <property name="username" type="string"/>
> >                        <property name="password" type="string"/>
> >                        <property name="email" type="string"/>
> >                        <property name="firstname" column="fname"
> > type="string"/>
> >                        <property name="lastname" column="lname"
> > type="string"/>
> >                </object>
>
> >        </objectDefinitions>
>
> > </transfer>
>
> > When I try to go and save the review (form on the product page) I get
> > this error but the record saves just fine.
>
> > Error Executing Database Query.
> > Column 'productId' specified twice
>
> > <cfif structKeyExists(form,"submit")>
>
> >        <cfset review = application.transfer.new("review")>
> >        <cfset review.setUserId(1)>
> >        <cfset review.setProductId(form.productId)>
> >        <cfset review.setRating(form.rating)>
> >        <cfset review.setComments(form.comments)>
> >        <cfset review.setDateReviewed(now())>
>
> >        <cfset product = application.transfer.get("product",form.productId)>
> >        <cfset review.setParentProduct(product)>
>
> >        <cfset application.transfer.save(review)>
> >        <cflocation url="product.cfm?id=#form.productId#" addtoken="false">
> >        <cfabort>
> > </cfif>
>
> --
> Paul Marcotte
> Fancy Bread - in the heart or in the head?http://www.fancybread.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to