RE: set method fails on relationship

From: JR Ruggentaler (j..pv.com)
Date: Wed Aug 21 2002 - 01:12:31 EDT

  • Next message: JR Ruggentaler: "RE: set method fails on relationship"

    I added the reverse relationship but PERSON.ADDRESS_ID is not getting set.

    Here is the log:
    [DEBUG DomainHelper] start configuration loading.
    [DEBUG DomainHelper] loaded domain: CayenneTstDomain
    [DEBUG DomainHelper] loading <map name='Map' location='Map'>.
    [DEBUG DomainHelper] loaded <map name='Map' location='Map'>.
    [DEBUG DomainHelper] loading <node name='Node' datasource='Node'
    factory='org.objectstyle.cayenne.conf.DriverDataSourceFactory'>.
    [DEBUG DomainHelper] node DbAdapter:
    org.objectstyle.cayenne.dba.mysql.MySQLAdapter
    [DEBUG DomainHelper] using factory:
    org.objectstyle.cayenne.conf.DriverDataSourceFactory
    [DEBUG DriverDataSourceFactory] loading driver information from (Node).
    [DEBUG DriverDataSourceFactory] location found in filesystem.
    [DEBUG DriverDataSourceFactory] loading driver org.gjt.mm.mysql.Driver
    [DEBUG DriverDataSourceFactory] loading user name and password.
    [DEBUG QueryLogger] Connecting. DataSource information:
    Driver class: org.gjt.mm.mysql.Driver
    Min. Pool Size: 1
    Max. Pool Size: 1
    Database URL: jdbc:mysql://localhost/Cayenne
    Login: root
    Password: *******
    [DEBUG QueryLogger] +++ Connecting: SUCCESS.
    [DEBUG DomainHelper] loaded datasource.
    [DEBUG DomainHelper] loaded map-ref: Map.
    [INFO QueryLogger] --- will run 2 queries.
    [INFO QueryLogger] SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME =
    'ADDRESS' - prepared in 0 ms.
    [INFO QueryLogger] === returned 1 row. - took 80 ms.
    [DEBUG DefaultOperationObserver] result count: 1
    [INFO QueryLogger] UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE
    TABLE_NAME = 'ADDRESS' - prepared in 0 ms.
    [INFO QueryLogger] === updated 1 row. [DEBUG DefaultOperationObserver]
    update count: 1
    [INFO QueryLogger] +++ transaction committed.
    [DEBUG DefaultOperationObserver] transaction committed
    [INFO QueryLogger] --- will run 1 query. [INFO QueryLogger] INSERT INTO
    ADDRESS (ADDRESS_ID, STREET_ADDRESS_2, CITY, STREET_ADDRESS_1, STATE, ZIP)
    VALUES (?, ?, ?, ?, ?, ?) [params: 280, NULL, 'Austin', '2000 Research
    Blvd', 'TX', '78759'] - prepared in 0 ms.
    [INFO QueryLogger] === updated 1 row.
    [DEBUG DefaultOperationObserver] update count: 1
    [INFO QueryLogger] +++ transaction committed.
    [DEBUG DefaultOperationObserver] transaction committed
    [INFO QueryLogger] --- will run 2 queries.
    [INFO QueryLogger] SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME =
    'PERSON' - prepared in 0 ms.
    [INFO QueryLogger] === returned 1 row. - took 0 ms. [DEBUG
    DefaultOperationObserver] result count: 1
    [INFO QueryLogger] UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE
    TABLE_NAME = 'PERSON' - prepared in 0 ms.
    [INFO QueryLogger] === updated 1 row. [DEBUG DefaultOperationObserver]
    update count: 1
    [INFO QueryLogger] +++ transaction committed. [DEBUG
    DefaultOperationObserver] transaction committed
    [INFO QueryLogger] --- will run 1 query.
    [INFO QueryLogger] INSERT INTO PERSON (PERSON_ID, FIRST_NAME,
    MIDDLE_INITIAL, LAST_NAME) VALUES (?, ?, ?, ?) [params: 220, 'John', 'H',
    'Cayenne'] - prepared in 0 ms.
    [INFO QueryLogger] === updated 1 row. [DEBUG DefaultOperationObserver]
    update count: 1
    [INFO QueryLogger] +++ transaction committed.
    [DEBUG DefaultOperationObserver] transaction committed

    Here is the Map:

    <?xml version="1.0" encoding="UTF-8"?>
    <data-map>
            <db-entity name="ADDRESS">
                    <db-attribute name="ADDRESS_ID" type="INTEGER"
    isPrimaryKey="true" isMandatory="true"/>
                    <db-attribute name="CITY" type="VARCHAR" length="20"/>
                    <db-attribute name="STATE" type="VARCHAR" length="2"/>
                    <db-attribute name="STREET_ADDRESS_1" type="VARCHAR"
    length="20"/>
                    <db-attribute name="STREET_ADDRESS_2" type="VARCHAR"
    length="20"/>
                    <db-attribute name="ZIP" type="VARCHAR" length="15"/>
            </db-entity>
            <db-entity name="PERSON">
                    <db-attribute name="ADDRESS_ID" type="INTEGER"/>
                    <db-attribute name="FIRST_NAME" type="VARCHAR" length="20"/>
                    <db-attribute name="LAST_NAME" type="VARCHAR" length="20"/>
                    <db-attribute name="MIDDLE_INITIAL" type="VARCHAR"
    length="1"/>
                    <db-attribute name="PERSON_ID" type="INTEGER"
    isPrimaryKey="true" isMandatory="true"/>
            </db-entity>
            <obj-entity name="Address" className="Address"
    dbEntityName="ADDRESS">
                    <obj-attribute name="city" type="java.lang.String"
    db-attribute-name="CITY"/>
                    <obj-attribute name="state" type="java.lang.String"
    db-attribute-name="STATE"/>
                    <obj-attribute name="streetAddress1" type="java.lang.String"
    db-attribute-name="STREET_ADDRESS_1"/>
                    <obj-attribute name="streetAddress2" type="java.lang.String"
    db-attribute-name="STREET_ADDRESS_2"/>
                    <obj-attribute name="zip" type="java.lang.String"
    db-attribute-name="ZIP"/>
            </obj-entity>
            <obj-entity name="Person" className="Person" dbEntityName="PERSON">
                    <obj-attribute name="firstName" type="java.lang.String"
    db-attribute-name="FIRST_NAME"/>
                    <obj-attribute name="lastName" type="java.lang.String"
    db-attribute-name="LAST_NAME"/>
                    <obj-attribute name="middleInitial" type="java.lang.String"
    db-attribute-name="MIDDLE_INITIAL"/>
            </obj-entity>
            <db-relationship name="address" source="PERSON" target="ADDRESS"
    toDependentPK="true" toMany="false">
                    <db-attribute-pair source="ADDRESS_ID" target="ADDRESS_ID"/>
            </db-relationship>
            <db-relationship name="toPerson" source="ADDRESS" target="PERSON"
    toDependentPK="false" toMany="true">
                    <db-attribute-pair source="ADDRESS_ID" target="ADDRESS_ID"/>
            </db-relationship>
            <obj-relationship name="address" source="Person" target="Address"
    toMany="false">
                    <db-relationship-ref source="PERSON" target="ADDRESS"
    name="address"/>
            </obj-relationship>
            <obj-relationship name="toPerson" source="Address" target="Person"
    toMany="true">
                    <db-relationship-ref source="ADDRESS" target="PERSON"
    name="toPerson"/>
            </obj-relationship>
    </data-map>

    J.R.
    -----Original Message-----
    From: Andrus [mailto:andru..bjectstyle.org]
    Sent: Tuesday, August 20, 2002 11:50 PM
    To: JR Ruggentaler
    Cc: cayenne-use..bjectstyle.org
    Subject: RE: set method fails on relationship

    At 10:09 AM 8/20/2002 -0500, you wrote:

    >Ok I changed the code as suggested by Andrus and I no longer get and
    >exception but when I look at the database PERSON.ADDRESS_ID is null so I
    >am back to my original problem. What's the correct method to set
    >relationships? Here is the new code.

    Hmm.. I have a similar JUnit test case that passes successfully.

    One idea. Try setting reverse relationship from address to person in the
    map. If it works after that, could you please file a bug at
    http://sourceforge.net/tracker/?group_id=48132&atid=452068 describing the
    situation?

    I can do this myself as well.

    Thanks

    Andrus



    This archive was generated by hypermail 2.0.0 : Wed Aug 21 2002 - 01:12:08 EDT