You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by David Warnock <da...@sundayta.com> on 2003/05/18 02:50:21 UTC

Proxy

Hi,

I have proxies working fine for collections which is great. I have a 
problem with proxies for foreign keys.

eg I have a contacts table and an emailAddresses table. The 
emailaddresses table has a foreign key pointing to contacts.

Within my contacts object I have a collection of emailaddresses and 
these are proxied fine using:

       <collection-descriptor
          name="emailAddresses"
          element-class-ref="org.visres.contact.data.EmailAddress"
          auto-retrieve="true"
          auto-update="true"
          auto-delete="false"
          proxy="true"
       >
          <orderby name="EmailAddress" sort="ASC"/>
          <inverse-foreignkey field-ref="contactId"/>
       </collection-descriptor>


My problem is that contacts has a foreign key pointing to emailaddresses 
for the default email address. I can't get this to proxy. When I try

       <field-descriptor
          name="emailAddressId"
          column="DefaultEmailId"
          jdbc-type="INTEGER"
       />

       <reference-descriptor
          name="emailAddress"
          class-ref="org.visres.contact.data.EmailAddress"
         proxy="true"
         auto-retrieve="true"
         auto-update="true"
         auto-delete="true">
          <foreignkey field-ref="emailAddressId"/>
       </reference-descriptor>

I get

java.util.NoSuchElementException: Could not obtain next object: Error 
setting field:emailAddress in object:org.visres.contact.data.Contact
     at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
     at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Unknown 
Source)
     at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Unknown 
Source)
     at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Unknown 
Source)
     at 
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(Unknown 
Source)
     at 
org.apache.ojb.broker.singlevm.DelegatingPersistenceBroker.getCollectionByQuery(Unknown 
Source)
     at 
org.visres.contact.controller.Contacts.getUiContacts(Contacts.java:277)

on this code

     Query query = new QueryByCriteria(Contact.class, null);
     iter = broker.getCollectionByQuery(query).iterator();  // line 277

Looking at the tutorial and at org.apache.ojb.broker.FarAwayReference I 
don't think I need a proxy class for this situation. What am I doing wrong?

Thanks

Dave
-- 
David Warnock, Sundayta Ltd. http://www.sundayta.com
iDocSys for Document Management. VisibleResults for Fundraising.
Development and Hosting of Web Applications and Sites.