At 06:09 PM 06/09/2004, Armin Waibel wrote:
Hi Brian,

sounds strange, do you use the anonymous keys in a 1:1 or 1:n relation? Which version do you use? Have you tried latest from CVS?
Can you describe me detailed a test case to reproduce the problem?

I'm using rc6. I have not tried the latest CVS version.

In the case causing problems, I think I am using anonymous keys only in 1:1 relations.

Here are the relevant code chunks

/********************************** Method to access database ***************************************/
public Collection getCollection(Object obj, String key, Object value) throws DataAccessException {


    Criteria criteria = null;
    Collection result = null;
    PersistenceBroker broker = null;
    QueryByCriteria query = null;

if (obj == null)
return result;
try {
broker = PersistenceBrokerFactory.defaultPersistenceBroker();
// Create criteria.
criteria = new Criteria();
criteria.addEqualTo(key, value); // Refine criteria
// Create Query
query = new QueryByCriteria(obj.getClass(), criteria);
result = broker.getCollectionByQuery(query);
} catch (Exception e) {
System.out.println("Error in getCollection: " + e.getMessage());
} finally {
if (broker != null)
broker.close(); // Release broker instance to the broker-pool
}


    return result;
  }

/******************************* Method calling getCollection ******************************/
public Collection getActiveEmployees() {
EmployeeBean staff = new EmployeeBean();
Vector staffList = new Vector();


try{
staffList = (Vector) dao.getCollection(staff, "statusTypeId", new Integer(1)); //@todo cleanup
}
catch (Exception e) {
System.out.println("Error in getEmployees: " + e.getMessage());
}
return staffList;
}



/**************************************** repository ****************************************/
<class-descriptor class="alpha.EmployeeBean" table="OPS.STAFFLIST">
<field-descriptor name="id" primarykey="true" default-fetch="true" column="STAFFID" jdbc-type="SMALLINT" autoincrement="true"
access="readonly"/>
<field-descriptor name="firstName" default-fetch="true" column="FIRSTNAME" jdbc-type="CHAR"/>
<field-descriptor name="middleName" default-fetch="true" column="MIDDLENAME1" jdbc-type="CHAR"/>
<field-descriptor name="lastName" nullable="false" default-fetch="true" column="LASTNAME" jdbc-type="CHAR"/>
<field-descriptor name="aspcaId" nullable="false" default-fetch="true" column="ASPCAID" jdbc-type="SMALLINT"/>
<field-descriptor name="staffTypeId" nullable="false" default-fetch="true" column="STAFFTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="statusTypeId" nullable="false" default-fetch="true" column="STATUSTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="login" default-fetch="true" column="LOGINNAME" jdbc-type="CHAR"/>


      <reference-descriptor
         name="details"
         class-ref="alpha.PersonDetailsBean"
         auto-retrieve="true"
        proxy="true">
         <foreignkey field-ref="id"/>
      </reference-descriptor>
      <collection-descriptor
            name="phoneNumbers"
            element-class-ref="alpha.PhoneNumberBean"
            proxy="true"
            >
            <inverse-foreignkey field-ref="callerId"/>
      </collection-descriptor>
      <collection-descriptor
            name="addresses"
            element-class-ref="alpha.AddressBean"
            proxy="true"
            >
            <inverse-foreignkey field-ref="id"/>
      </collection-descriptor>
 </class-descriptor>


<class-descriptor class="alpha.PersonDetailsBean" table="OPS.STAFFDETAIL">
<field-descriptor name="id" primarykey="true" default-fetch="true" column="STAFFID" jdbc-type="SMALLINT" />
<field-descriptor name="genderId" nullable="false" column="GENDERTYPEID" jdbc-type="SMALLINT" access="anonymous" />
<field-descriptor name="maritalStatusId" nullable="false" column="MARITALTYPEID" jdbc-type="SMALLINT" access="anonymous"/>
<field-descriptor name="dateOfBirth" default-fetch="true" column="BIRTHDATE" jdbc-type="DATE"/>
<field-descriptor name="whenEntered" nullable="false" default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
<field-descriptor name="notes" default-fetch="true" column="BIOSKETCH" jdbc-type="VARCHAR"/>


    <reference-descriptor
         name="maritalStatus"
         class-ref="alpha.MaritalStatusBean"
         auto-retrieve="true">
         <foreignkey field-ref="maritalStatusId"/>
    </reference-descriptor>
    <reference-descriptor
         name="gender"
         class-ref="alpha.GenderBean"
         auto-retrieve="true">
         <foreignkey field-ref="genderId"/>
    </reference-descriptor>

    </class-descriptor>


<class-descriptor class="alpha.GenderBean" table="OPS.GENDERTYPE">
<field-descriptor name="id" primarykey="true" default-fetch="true" column="GENDERTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="name" nullable="false" default-fetch="true" column="GENDERTYPENAME" jdbc-type="CHAR"/>
<field-descriptor name="dscrp" default-fetch="true" column="GENDERTYPEDSCRP" jdbc-type="CHAR"/>
<field-descriptor name="whenEntered" nullable="false" default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
</class-descriptor>
<class-descriptor class="alpha.MaritalStatusBean" table="OPS.MARITALTYPE">
<field-descriptor name="id" primarykey="true" default-fetch="true" column="MARITALTYPEID" jdbc-type="SMALLINT"/>
<field-descriptor name="name" nullable="false" default-fetch="true" column="MARITALTYPENAME" jdbc-type="CHAR"/>
<field-descriptor name="dscrp" default-fetch="true" column="MARITALTYPEDSCRP" jdbc-type="CHAR"/>
<field-descriptor name="whenEntered" nullable="false" default-fetch="true" column="WHENENTERED" jdbc-type="TIMESTAMP"/>
</class-descriptor>


/******************************************************* What happens *********************************************/
The code above is producing the results I want, but I am forced to use proxies.
IF I remove the proxy="true" from PersonDetailsBean, then the MaritalStatus and GenderBean contained within are both null when I attempt to access them even though auto-retrieve="true". However the PersonDetailsBean itself is not null and I can access properties such as dateOfBirth just fine.





thanks much for any suggestions,

Brian




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



Reply via email to