Re: problem with flattened relationship

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Dec 07 2004 - 21:10:59 EST

  • Next message: Steve Wells: "NPE calling SQL Server 2K Stored Procedure"

    > <obj-relationship name="products" source="List" target="Product"
    > db-relationship-path="productlists.product"/>
    > <obj-relationship name="products" source="User" target="Product"
    > db-relationship-path="lists.productlists.product"/>

    > whenever I remove a product from a list, my user.products flattened
    > relationship is not updated.

    Hmm... you have one flattened relationship overlapping another:

    lists.productlists.product
    ***** productlists.product

    Cayenne most certainly will not handle the refresh properly. I am not
    sure that we should... But anyway, you can handle this manually. E.g.
    by overriding List.removeFromProducts() -

    public void removeFromProducts(Product p) {
        super.removeFromProducts(p);

        List userProducts = getUser().getProducts();

        // uncomment this line if simply doing "remove" causes uneeded fetch
        // if(!((ToManyList) userProducts).needsFetch())
        userProducts.remove(p);
    }

    Something similar for "addToProducts()".

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Dec 07 2004 - 21:11:05 EST