Wally you are a live saver!!! I just forgot to set the reference object
person in class activity. Now it works! thanks for your hint. 

-----Ursprüngliche Nachricht-----
Von: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 9. Februar 2004 15:27
An: OJB Users List
Betreff: RE: foreign key is not being updated...
Vertraulichkeit: Persönlich

Hi Dirk,

It looks like you are setting the FK and not the reference object.
Therefore, on an update, OJB is resolving and updating the FK of the set
reference object (null!).  If you want to continue setting the FK, you must
call pb.resolveReference("reference"); to set the object prior to the store
call.

Hope this helps,

Wally

-----Original Message-----
From: Dirk Manske (Service Respond)
[mailto:[EMAIL PROTECTED]
Sent: Monday, February 09, 2004 5:38 AM
To: 'OJB Users List'
Subject: AW: foreign key is not being updated...
Sensitivity: Personal


I am still struggling to update a foreign key (see below). I try


pm.beginTransaction;

while(thereAreMoreSchedules){
        schedule.set(startDate);
        schedule.set(endDate);

        activity.setTimestamp(...)
        activity.setPersonId(personId); //1:N reference from person to
activity

        schedule.set(activity); //1:N reference from schedule to activity

        pm.store(schedule);
}

pm.commitTransaction;

pm.close();

On the first time and insert is done succesfully. When I try an update, only
the field timestamp is being updated, personId not. I can't believe, OJB
cannot handle this. Why is it not working????????

Dirk


 

-----Ursprüngliche Nachricht-----
Von: Dirk Manske (Service Respond)
[mailto:[EMAIL PROTECTED] 
Gesendet: Montag, 9. Februar 2004 02:12
An: 'OJB Users List'
Betreff: foreign key is not being updated...
Vertraulichkeit: Persönlich

Hi,

I am using the PB-API and struggle with update fk references in the db.

There are three tables Person --> Activity --> Schedule.
Person has a 1:N assoc to Activity. Activity has a 1:N assoc to Schedule.

While you plan the schedule you have to select a person which will be
assigned to the selected activity. For the first time, doing an insert works
well. If you want to change the person, an update fails. There is no error
message though, everything seems fine. I tested it by setting some values
and did an update to the db. All values had been updated, except the fk for
personid in table Activity. Here are the facts:

Activity holds a fk for table Person. Schedule holds a fk for table
Activity. The repository excerpt is as follows:

<!-- table TPPERSON -->
<class-descriptor class="de.premiere.plato.app.person.entity.PersonModel"
table="PLATO.TPPERSON" >
        <field-descriptor id="1"        name="intPersonId"
column="PERSON_ID"  jdbc-type="INTEGER" primarykey="true"
autoincrement="true" access="readonly" />
        ...
    <collection-descriptor
        name="allAssignedActivities"
        element-class-ref="de.plato.activity.entity.ActivityModel"

        orderBy="intActivityId"
        sort="DESC"

        auto-retrieve="true"
        auto-update="true"
        auto-delete="true" >

            <inverse-foreignkey field-ref="intPersonId" />
    </collection-descriptor>
</class-descriptor>


<!-- TPACTIVITY -->
<class-descriptor class="de.plato.app.activity.entity.ActivityModel"
table="PLATO.TPACTIVITY" >
        <field-descriptor id="1"        name="intActivityId"
column="ACTIVITY_ID"            jdbc-type="INTEGER" primarykey="true"
autoincrement="true" access="readonly" />
        ...
        <field-descriptor id="8"        name="intPersonId"
column="PERSON_ID"              jdbc-type="INTEGER" />
        ...
        <reference-descriptor name="personModel"
                class-ref="de.premiere.plato.app.person.entity.PersonModel"
                refresh="true"

                auto-retrieve="true"
                auto-update="true"  >

                <foreignkey field-id-ref="8" />
        </reference-descriptor>

        <collection-descriptor
                name="allAssignedSchedules"
        
element-class-ref="de.plato.app.schedule.entity.ScheduleModel"
                orderBy="intScheduleId"
                sort="DESC"

                auto-retrieve="true"
                auto-update="true"
                auto-delete="true" >

            <inverse-foreignkey field-ref="intActivityId" />
    </collection-descriptor>
</class-descriptor>


<!-- TPSSCHEDULE -->
<class-descriptor
class="de.premiere.plato.app.schedule.entity.ScheduleModel"
table="PLATO.TPSCHEDULE" >
        <field-descriptor id="1"        name="intScheduleId"
column="SCHEDULE_ID"        jdbc-type="INTEGER" primarykey="true"
autoincrement="true" access="readonly" />
        ...
        <field-descriptor id="11"       name="intActivityId"
column="ACTIVITY_ID"       jdbc-type="INTEGER" />
    <reference-descriptor name="activity"
                class-ref="de.plato.app.activity.entity.ActivityModel"
                refresh="true"

                auto-retrieve="true" >

                <foreignkey field-id-ref="11" />
        </reference-descriptor>
</class-descriptor>


The pk's are primitive integers. I just store the collection
'allAssignedSchedules' in a while loop with broker.store(scheduleObject).
Again, this works well for all attributes except the fk of personId in table
Activity. I do not why. Does someone have an idea?

thx,
Dirk 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to