Can not recognize the object passed in for the toOne relationship?

From: Bill Fan (bil..anscom.com.au)
Date: Fri Apr 21 2006 - 00:41:12 EDT

  • Next message: Andrus Adamchik: "Re: PK problem with Postgre"

    Hi,

    I'm trying to do something like the following and it seems the productId
    becomes null in the generated sql query.

    Price price = new Price();
    threadDataContext().registerNewObject(price);
    price.setToProduct(product);
    price.setPrice(o.getPrice());
    ...

    The query generated was as following:
    ------------------------------------
    INSERT INTO dbo.Price (Description, GST, IsUnitPrice, Price, PriceId,
    PriceTypeId, ProductId, Qty) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
    [bind: '1 box', 10, 'true', 100, 280, 1, NULL, 1]

    I'm using Tomcat 5.0.28 + Spring 1.2.7 + Cayenne 1.1.4 + Struts 1.2.9

    I can see and verify the productId value and the product name by placing the
    following logging statements before the product object is used,
            Log.debug("product Id: " + product.getProductId());
            Log.debug("product Name: " + product.getProductName());

    More details are as follow if it is required:
    =============================================
    In the web app, there are a Product table and a Price table. It is a "one to
    many" relation from Product to Price,

    The tables:
    -----------
    Product table:
            proudctId int PK
            productName varchar(100)
            ...

    Price table:
            priceId int PK,
            productId int FK (to Product.ProductId column)
            price double
            ...

    Cayenne data map:
    -----------------
    <db-relationship name="toProduct" source="Price" target="Product"
    toMany="false">
            <db-attribute-pair source="ProductId" target="ProductId"/>
    </db-relationship>

    <db-relationship name="priceArray" source="Product" target="Price"
    toMany="true">
                    <db-attribute-pair source="ProductId" target="ProductId"/>
    </db-relationship>

    Many thanks in advance!
    Bill



    This archive was generated by hypermail 2.0.0 : Fri Apr 21 2006 - 00:41:45 EDT