Have you tried swapping the two "foreignkey field-id-ref"s ?

-----Oprindelig meddelelse-----
Fra: Gilles Dodinet [mailto:g.dodinet@;cross-systems.com] 
Sendt: 14. november 2002 17:32
Til: [EMAIL PROTECTED]
Emne: 1-1 Association throws ArrayIndexOutOfBoundsException


hi,

I'm new to ojb and encounter some difficulties with 1-1 associations
mapping. I've searched through the list but haven't found an answer.
Though i think the two threads linked at the bottom of the message are
related to my problem but have no reply.

I have a bidirectional 1-1 association between classes Article and
Remise and my mapping looks like :

<class-descriptor class="com.csi.jdo.bench.business.Article"
table="ARTICLE">
  ... (some fields)
  <field-descriptor id="4" name="ojbRemiseId" column="REF_REMISE"
jdbc-type="INTEGER"/>
  <reference-descriptor name="remise"
class-ref="com.csi.jdo.bench.business.Remise">
    <foreignkey field-id-ref="4"/>
  </reference-descriptor>
</class-descriptor>

<class-descriptor class="com.csi.jdo.bench.business.Remise"
table="REMISE">
  ... (some fields)
  <field-descriptor id="8" name="ojbArticleId" column="REF_ARTICLE"
jdbc-type="INTEGER"/>
  <reference-descriptor name="article"
class-ref="com.csi.jdo.bench.business.Article">
    <foreignkey field-id-ref="8"/>
  </reference-descriptor>
</class-descriptor>

When i try to query the Remises i got the exception below :

[org.apache.ojb.broker.accesslayer.RsIterator] ERROR: null
java.lang.ArrayIndexOutOfBoundsException
 at
org.apache.ojb.broker.metadata.ClassDescriptor.getFieldDescriptorByIndex
(Unk
nown Source)
 at
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFi
eldD
escriptors(Unknown Source)
 at
org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyVa
lues
(Unknown Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject
(Unk
nown Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReference(U
nkno
wn Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReferences(
Unkn
own Source)
 at
org.apache.ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(Unkn
own
Source)
 at org.apache.ojb.broker.accesslayer.RsIterator.next(Unknown Source)
at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Un
known Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Un
known Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Un
known Source)
 at
org.apache.ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuer
y(Un
known Source)
 at org.apache.ojb.jdo.JDOQuery.execute(Unknown Source)

I suspect this exception comes from a java.util.NoSuchElementException
thrown by RSIterator.next() qince the StackTrace printed to the console
and the junit one are not the same.

When i comment the reference-descriptor in the Remise descriptor, this
problem disappears ; then the referenced Article is always null, but at
least ojb doesnt complain. I guess i'm doing something wrong but cannot
see what. Any help would be welcome.

I've tried both the OJB JDO API (the one i'm planning to use) and the
PersistenceBroker API. In both case i got that exception.


Thanks for your help.

regards,

-- gd

related threads ?
http://archives.apache.org/eyebrowse/ReadMsg?listName=ojb-user@;jakarta.a
pach
e.org&msgId=389869
http://archives.apache.org/eyebrowse/ReadMsg?listName=ojb-user@;jakarta.a
pach
e.org&msgId=507762





--
To unsubscribe, e-mail:
<mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:ojb-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to