Thomas, I tried removing the collection-class entry and it had no effect. The only difference in the two executions is the existence of the reference from Trait to Person. When that is in place, the traPerOID field is not updated with the person's OID. This is smelling more like a bug. Is there additional information or source code that I should provide to help in tracking this down?

Thanks.

Thomas Mahler wrote:

Hi Larry,

Hmm, I had a look at your code and did find any flaws.
Did you try to ommit the collection-class entry?
I think it is at least superfluous.

But I have no idea what could be wrong here, as your repository looks OK.

Thomas

Larry V. Streepy, Jr. wrote:

I'm working on a fairly simple sample program (modified from the tutorial1 code shipped with OJB) and I'm running into some unexplainable (by me :-) behavior relating to a 1:N relation.

The relationship is a simple 1:N from a Person object to a Trait object. I've attached the repository_user.xml and the source code in question.

As attached, the subordinate Trait objects are properly stamped with the OID of the Person object. However, if I uncomment the "reference-descriptor" in Trait (making it a traversable relation from Trait to Person), the Trait objects are not stamped with the Person object's OID when they are persisted. I'm sure that I just don't understand the interplay between these conditions, so if anybody can explain it, it would help a lot.

Note, you can ignore all the fields relating to timestamp, lock, lastModified, etc. They are artifacts put in by AXgen and are irrelevant.

Thanks.
--
Larry V. Streepy, Jr.
Senior Vice President and CTO
Health Language, Inc.


------------------------------------------------------------------------


<class-descriptor class="com.staffmix.nurse.competencies.TraitImpl"
table="Trait">
<field-descriptor autoincrement="true" primarykey="true" column="traOID" jdbc-type="VARCHAR" name="OID"/>
<field-descriptor column="traLockTimestamp" jdbc-type="TIMESTAMP" name="lockTimestamp"/>
<field-descriptor column="traLockUser" jdbc-type="VARCHAR" name="lockUser"/>
<field-descriptor column="traLastModified" jdbc-type="TIMESTAMP" name="lastModified"/>
<field-descriptor column="traLastModifier" jdbc-type="VARCHAR" name="lastModifier"/>
<field-descriptor column="traTraitName" jdbc-type="VARCHAR" name="traitName"/>
<field-descriptor column="traPersonOID" jdbc-type="VARCHAR" name="personOID"/>
<!--
<reference-descriptor proxy="true"
auto-delete="false" auto-retrieve="true" auto-update="false"
class-ref="com.staffmix.nurse.competencies.PersonImpl"
name="person">
<foreignkey field-ref="personOID"/>
</reference-descriptor>
-->
</class-descriptor>


<class-descriptor class="com.staffmix.nurse.competencies.CompetencyImpl"
table="Competency">
<field-descriptor autoincrement="true" primarykey="true" column="comOID" jdbc-type="VARCHAR" name="OID"/>
<field-descriptor column="comLockTimestamp" jdbc-type="TIMESTAMP" name="lockTimestamp"/>
<field-descriptor column="comLockUser" jdbc-type="VARCHAR" name="lockUser"/>
<field-descriptor column="comLastModified" jdbc-type="TIMESTAMP" name="lastModified"/>
<field-descriptor column="comLastModifier" jdbc-type="VARCHAR" name="lastModifier"/>
<field-descriptor column="comName" jdbc-type="VARCHAR" name="name"/>
<field-descriptor column="comDescription" jdbc-type="VARCHAR" name="description"/>
<collection-descriptor proxy="true"
collection-class="org.apache.ojb.broker.util.collections.ManageableVector"


    auto-delete="false" auto-retrieve="true" auto-update="false"
    element-class-ref="com.staffmix.nurse.competencies.PersonImpl"
    indirection-table="CompetencyPerson"
    name="persons"
  >
    <fk-pointing-to-this-class column="competencyOID"/>
    <fk-pointing-to-element-class column="personOID"/>
  </collection-descriptor>
</class-descriptor>

<class-descriptor class="com.staffmix.nurse.competencies.PersonImpl"
table="Person">
<field-descriptor autoincrement="true" primarykey="true" column="perOID" jdbc-type="VARCHAR" name="OID"/>
<field-descriptor column="perLockTimestamp" jdbc-type="TIMESTAMP" name="lockTimestamp"/>
<field-descriptor column="perLockUser" jdbc-type="VARCHAR" name="lockUser"/>
<field-descriptor column="perLastModified" jdbc-type="TIMESTAMP" name="lastModified"/>
<field-descriptor column="perLastModifier" jdbc-type="VARCHAR" name="lastModifier"/>
<field-descriptor column="perEmpid" jdbc-type="VARCHAR" name="empid"/>
<field-descriptor column="perName" jdbc-type="VARCHAR" name="name"/>
<collection-descriptor proxy="true"
collection-class="org.apache.ojb.broker.util.collections.ManageableVector"


auto-delete="true" auto-retrieve="true" auto-update="true"
element-class-ref="com.staffmix.nurse.competencies.TraitImpl"
orderby="traitName"
name="traits"
>
<inverse-foreignkey field-ref="personOID"/>
</collection-descriptor>
<collection-descriptor proxy="true"
collection-class="org.apache.ojb.broker.util.collections.ManageableVector"


    auto-delete="false" auto-retrieve="true" auto-update="false"
    element-class-ref="com.staffmix.nurse.competencies.CompetencyImpl"
    indirection-table="CompetencyPerson"
    name="competencys"
  >
    <fk-pointing-to-this-class column="personOID"/>
    <fk-pointing-to-element-class column="competencyOID"/>
  </collection-descriptor>
</class-descriptor>


------------------------------------------------------------------------


package com.staffmix.nurse.play;

import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerException;
import com.staffmix.nurse.competencies.PersonImpl;
import com.staffmix.nurse.competencies.Trait;
import com.staffmix.nurse.competencies.TraitImpl;

/**
 * Insert the type's description here.
 * Creation date: (04.03.2001 10:34:15)
 * @author Thomas Mahler
 */
public class UCEnterNewPerson extends AbstractUseCase
{
    /**
     * UCEnterNewProduct constructor comment.
     */
    public UCEnterNewPerson(PersistenceBroker broker)
    {
        super(broker);
    }

    /** perform this use case*/
    public void apply()
    {
        // this will be our new object
        PersonImpl newPerson = new PersonImpl();
        // now read in all relevant information and fill the new object:
        System.out.println("please enter a new person");
        String in = readLineWithMessage("enter name:");
        newPerson.setName(in);
        in = readLineWithMessage("enter empid:");
        newPerson.setEmpid(in);

        // now perform persistence operations
        try
        {
            // 1. open transaction
            broker.beginTransaction();

while( (in = readLineWithMessage("Enter trait:")) != null ) {
String traitName = in.trim();
if( traitName.length() == 0 )
break;
TraitImpl trait = new TraitImpl();
trait.setTraitName( traitName );
newPerson.addTrait( trait );
}


            // 2. make the new object persistent
            broker.store(newPerson);
            broker.commitTransaction();
        }
        catch (PersistenceBrokerException ex)
        {
            // if something went wrong: rollback
            broker.abortTransaction();
            System.out.println(ex.getMessage());
            ex.printStackTrace();
        }
    }

    /** get descriptive information on use case*/
    public String getDescription()
    {
        return "Enter a new person";
    }
}



------------------------------------------------------------------------

---------------------------------------------------------------------
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]



-- Larry V. Streepy, Jr. Senior Vice President and CTO Health Language, Inc.

Reply via email to