problem with flattened relationship

From: Fernando Donati (fernand..onati.com.br)
Date: Tue Dec 07 2004 - 10:59:43 EST

  • Next message: Andrus Adamchik: "Re: DataContext XML serialization"

    Hi everybody,

    I'm having a hard time figuring out this one.

    I have four db entities (user, list, product_list and product) and
    three object entities (User, List and Product).

    user <->> list <->> product_list <<-> product

    Everything works great, I can add products to a list, remove, remove
    lists, etc. There's just one thing: whenever I remove a product from a
    list, my user.products flattened relationship is not updated. I can't
    remove it directly from the user (with the user.removeFromProducts
    method) because the same product can appear in more than one list.

    Any hints on what I'm doing wrong?

    Thanks is advance!

    Fernando Donati

    P.S. Here's the relevant part of the datamap:

            <db-entity name="dcp_product">
                    <db-attribute name="barcode" type="VARCHAR" length="30"/>
                    <db-attribute name="id" type="INTEGER" isPrimaryKey="true"
    isMandatory="true"/>
                    <db-attribute name="name" type="VARCHAR" isMandatory="true"
    length="100"/>
                    <db-attribute name="pid" type="CHAR" length="5"/>
                    <db-attribute name="reference" type="VARCHAR" isMandatory="true"
    length="30"/>
            </db-entity>
            <db-entity name="dcp_productlist">
                    <db-attribute name="list_id" type="INTEGER" isPrimaryKey="true"
    isMandatory="true"/>
                    <db-attribute name="product_id" type="INTEGER" isPrimaryKey="true"
    isMandatory="true"/>
            </db-entity>
            <db-entity name="sr_usuario">
                    <db-attribute name="email" type="VARCHAR" isMandatory="true"
    length="128"/>
                    <db-attribute name="id" type="INTEGER" isPrimaryKey="true"
    isMandatory="true"/>
                    <db-attribute name="nome" type="VARCHAR" isMandatory="true"
    length="64"/>
                    <db-attribute name="sobrenome" type="VARCHAR" isMandatory="true"
    length="64"/>
            </db-entity>
            <obj-entity name="List" className="com.donati.List"
    dbEntityName="dcp_list">
                    <obj-attribute name="name" type="java.lang.String"
    db-attribute-path="name"/>
            </obj-entity>
            <obj-entity name="Product" className="com.donati.Product"
    dbEntityName="dcp_product">
                    <obj-attribute name="barcode" type="java.lang.String"
    db-attribute-path="barcode"/>
                    <obj-attribute name="name" type="java.lang.String"
    db-attribute-path="name"/>
                    <obj-attribute name="pid" type="java.lang.String"
    db-attribute-path="pid"/>
                    <obj-attribute name="reference" type="java.lang.String"
    db-attribute-path="reference"/>
            </obj-entity>
            <obj-entity name="User" className="com.donati.User"
    dbEntityName="sr_usuario">
                    <obj-attribute name="email" type="java.lang.String"
    db-attribute-path="email"/>
                    <obj-attribute name="firstname" type="java.lang.String"
    db-attribute-path="nome"/>
                    <obj-attribute name="lastname" type="java.lang.String"
    db-attribute-path="sobrenome"/>
            </obj-entity>

            <db-relationship name="productlists" source="dcp_list"
    target="dcp_productlist" toDependentPK="true" toMany="true">
                    <db-attribute-pair source="id" target="list_id"/>
            </db-relationship>
            <db-relationship name="user" source="dcp_list" target="sr_usuario"
    toMany="false">
                    <db-attribute-pair source="user_id" target="id"/>
            </db-relationship>
            <db-relationship name="productlists" source="dcp_product"
    target="dcp_productlist" toDependentPK="true" toMany="true">
                    <db-attribute-pair source="id" target="product_id"/>
            </db-relationship>
            <db-relationship name="list" source="dcp_productlist"
    target="dcp_list" toMany="false">
                    <db-attribute-pair source="list_id" target="id"/>
            </db-relationship>
            <db-relationship name="product" source="dcp_productlist"
    target="dcp_product" toMany="false">
                    <db-attribute-pair source="product_id" target="id"/>
            </db-relationship>
            <db-relationship name="lists" source="sr_usuario" target="dcp_list"
    toMany="true">
                    <db-attribute-pair source="id" target="user_id"/>
            </db-relationship>

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



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