You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Michael Mogley <mm...@adelphia.net> on 2004/01/24 21:16:20 UTC
regression in CollectionProxy?
Hi all,
I recently updated my two-month old OJB with the latest version (as of this
morning). In my web-app, I have a section of code that retrieves a
CollectionProxy of photos from an album. When this collection is copied to
an ArrayList, I get a stack. This code was working before the update.
I've looked at the source and it seems the CollectionProxy.toArray
materializes the real subjects. If so, why?
Any help greatly appreciated.
Michael
CODE-SNIPPET
-------------------
Collection photos = album.getPhotos();
ArrayList photoArray = new ArrayList(photos);
STACK
---------
2004-01-24 11:12:22 StandardWrapperValve[jsp]: Servlet.service() for servlet
jsp threw exception
java.lang.NullPointerException
at
org.apache.ojb.broker.accesslayer.CollectionPrefetcher.associateBatched(Coll
ectionPrefetc
her.java:190)
at
org.apache.ojb.broker.accesslayer.BasePrefetcher.prefetchRelationship(BasePr
efetcher.java
:150)
at
org.apache.ojb.broker.core.QueryReferenceBroker$PBPrefetchingListener.prefet
ch(QueryRefer
enceBroker.java:837)
at
org.apache.ojb.broker.core.QueryReferenceBroker$PBCollectionProxyListener.be
foreLoading(Q
ueryReferenceBroker.java:894)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.beforeLoading(CollectionPr
oxy.java:173)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.getData(CollectionProxy.ja
va:400)
at
org.apache.ojb.broker.accesslayer.CollectionProxy.toArray(CollectionProxy.ja
va:246)
at java.util.ArrayList.<init>(ArrayList.java:136)
MAPPING (trimmed irrelevant bits)
------------------------------------
<!DOCTYPE descriptor-repository PUBLIC "-//Apache Software Foundation//DTD
OJB Repository//EN" "http://db.apache.org/ojb/dtds/1.0/repository.dtd">
<descriptor-repository version="1.0" isolation-level="read-uncommitted"
proxy-prefetching-limit="50">
<!-- Album -->
<class-descriptor class="me.db.Album" table="ALBUM">
<!-- Primary Key -->
<field-descriptor name="ID" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" access="readonly"/>
<!-- Primitives -->
<field-descriptor name="name" column="NAME"
jdbc-type="VARCHAR"/>
<!-- Collections -->
<collection-descriptor name="photos" element-class-ref="me.db.Photo"
auto-retrieve="true"
auto-delete="true"
proxy="true"
>
<inverse-foreignkey field-ref="albumID"/>
</collection-descriptor>
</class-descriptor>
<!-- Photo -->
<class-descriptor class="me.db.Photo" table="PHOTO">
<!-- Primary Key -->
<field-descriptor name="ID" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true" access="readonly"/>
<!-- Foreign Keys -->
<field-descriptor name="albumID" column="ALBUM_ID"
jdbc-type="INTEGER" access="anonymous"/>
<!-- Primitives -->
<field-descriptor name="name" column="NAME"
jdbc-type="VARCHAR"/>
<!-- References -->
<reference-descriptor name="album" class-ref="me.db.Album"
auto-retrieve="true"
auto-delete="false"
auto-update="false"
>
<foreignkey field-ref="albumID"/>
</reference-descriptor>
</class-descriptor>
<class-descriptor class="me.db.PhotoProxy">
<extent-class class-ref="me.db.Photo"/>
</class-descriptor>
</descriptor-repository>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org