Hi,

I have a table (news) where I put some infos. I'd like to associate some documents to these news (maybe none). These documents resides in the table documents. I've created an association table called newsdocs, where there are the two id's: one for news and one for documents.

The modeler recorgnises the relashionships (infact the object Newsdocs has only thwo relationships: toDocuments, toNews. Also in the object News there is an array (newsdocsArray) and in the object Documents (newsdocsArray).

How can I create a relation between a news and a document?

I have tried:

1) created News: nw1 (via createANdRegisterNewObject)
2) created Documents: doc2 (via createANdRegisterNewObject)
3) commit
4) created a black record for Newsdocs:

Newsdocs ndoc = new Newsdocs();
ndoc.setDataContext(...) // the same used in (via createANdRegisterNewObject)
ndoc.setToDocuments(doc2); //****** NullPointerException
ndoc.setToNews(nw1);
doc2.addToNewsdocsArray(ndoc);
nw1.add(via createANdRegisterNewObject)

5) commit

Unfortunatly this doesn't work: there is a NullPointerException in ******

Maybe I need to understand better the use of relashionships. Any suggestion is wellcome!
Thanks a lot

-- Ivan

Reply via email to