Re: help with non decomposed M:N

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Ramzi Oueslati wrote:
> Hi Armin,
> 
> Thank you for your reply. Sure I can and here it is.
> 
> This is when I try to update an already persisted instance of A :
> 
> java.lang.NullPointerException
>    at 
> org.apache.ojb.broker.metadata.DescriptorRepository.getDescriptorFor(DescriptorRepository.java:409) 
> 
>    at 
> org.apache.ojb.broker.core.MtoNBroker.getMtoNImplementor(MtoNBroker.java:129) 
>

Think I got your problem. The NPE is caused by a invalid mapping.

Your look like:

<collection-descriptor name="cs" 
collection-class="org.apache.ojb.broker.util.collections.ManageableArrayList"
        element-class="my.test.business.C"
        auto-retrieve="false" auto-update="link"
        indirection-table="TBLAC">
        <fk-pointing-to-this-class column="A_ID" />
        <fk-pointing-to-element-class column="C_ID" />
</collection-descriptor>


a correct mapping look like:

<collection-descriptor name="authors" 
element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Author"
         indirection-table="SQLCOUNT_PUBLICATION"
         proxy="true"
         auto-retrieve="true"
         auto-update="object"
         auto-delete="object"
         >
         <fk-pointing-to-this-class column="MEDIUM_ID"/>
         <fk-pointing-to-element-class column="AUTHOR_ID"/>
     </collection-descriptor>
</class-descriptor>

as you can see it differs in one attribute, you use "element-class" 
instead of "element-class-ref" and this cause the NPE.

By the way, it's recommended to use the latest version of OJB (1.0.4).

Good luck!
regards,
Armin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.