I am using the ODMG implementation of OJB version 0.9.4.

Is the following behavior a bug or I am missing something in the way I have defined my 
objects and/or reporsitory file? 

I am  trying to use the concept of "single proxy for a whole collection" as described 
in tutorial 3  (in my example code a SimplePerson has multiple SimpleAccount.  
I found that the Account instances are being instantiated whenever the SimplePerson is 
retrieved. 

To prove my case I run the following test case  with debug on 

      String oqlQuery = "select result from test.dsf.SimplePerson where id = 2 " ;
      OQLQuery query = odmg.newOQLQuery();
      query.create(oqlQuery);
      DList result = (DList) query.execute();

and the following OQL appeared in the log when query.execute()  is called, 
illustrating that the accounts are being retrieved along with the person.

SELECT A0.PERSONID,A0.ACCOUNTNAME,A0.ACCOUNTNO,A0.AccountId FROM Account A0 WHERE 
A0.PERSONID = ?



package test.dsf;
import java.util.*;
public class SimplePerson  {
  private Integer id;
  private String firstName;
  private String lastName;
  private Integer addressId;
  private Collection accounts;
  public SimplePerson() { }
  public SimplePerson(Integer id, String fn, String ln, Integer aid) {
    this.id = id;
    firstName = fn;
    lastName = ln;
    addressId = aid;
  }
  public String getFirstName() {
    return firstName;
  }
  public void setFirstName(String name) {
    firstName = name;
  }
  public Collection getAccounts() {
    return accounts;
  }
  public void  setAccounts(Collection coll) {
    accounts = coll;
  }

package test.dsf
public class SimpleAccount  {
  private Integer id;
  private String accountName;
  private String accountNo;
  private Integer personId;
  public SimpleAccount() { }

  public SimpleAccount(Integer id,String accountName, String accountNo, Integer 
personId) {
    this.id = id;
    this.accountNo = accountNo;
    this.accountName = accountName;
    this.personId = personId;
  }
}

   <class-descriptor
          class="test.dsf.SimplePerson"
          table="PERSON"
   >
      <field-descriptor id="1"
         name="id"
         column="ID"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="true"
      />
      <field-descriptor id="2"
         name="firstName"
         column="FIRSTNAME"
         jdbc-type="VARCHAR"
      />
      <field-descriptor id="3"
         name="lastName"
         column="LASTNAME"
         jdbc-type="VARCHAR"
      />

      <field-descriptor id="4"
         name="addressId"
         column="ADDRESSID"
         jdbc-type="INTEGER"
      />

      <collection-descriptor
         name="accounts"
         element-class-ref="test.dsf.SimpleAccount"
                        proxy="true"
                        auto-retrieve="false"
                                        >
         <inverse-foreignkey field-id-ref="4"/>
      </collection-descriptor>  
        </class-descriptor>









}









Regards

Denis St Flour


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

Reply via email to