Re: AW: [OJB-developers] Using CollectionDescriptor in repository.xml
Brought to you by:
thma
From: Thomas M. <tho...@ho...> - 2002-03-22 17:53:54
|
Hi again, Leandro Rodrigo Saad Cruz wrote: > Sorry man, in fact the problem was in another line at repository.xml > I defined a ReferenceDescriptor that pointed to the wrong class field. >=20 >=20 > By the way. If I have a association like this A 1 ----- N B >=20 > Do I have to defined CollectionDescriptors(from A to B) and > ReferenceDescriptos( from B to A) or just one of them ?? >=20 Depends. If you want to navigate from A to the Bs only you'll need a=20 CollectionDescriptor in ClassDescriptor A. If you want to navigate from a B to its A only you'll need a=20 ReferenceDescriptor in ClassDescriptor B. If you want to navigate in both directions you'll need both. HTH, Thomas >=20 > On Fri, 2002-03-22 at 12:20, Mahler Thomas wrote: >=20 >>Hi Leandro, >> >>I'll try to explain the 1-n section from the tutorial3. >>Say you have a class ProductGroup with a Vector attribute allArticlesIn= Group >> that holds all Article objects belonging to this group. >> >>That is: *one* ProductGroup holds *n* Articles. >> >>You must tell OJB how to load the allArticlesInGroup attribute on loadi= ng a >>ProductGroup object. >>This is done by the following CollectionDescriptor: >><ClassDescriptor id=3D"2"> >> <class.name>test.ojb.broker.ProductGroup</class.name> >> ... >> <CollectionDescriptor id=3D"1"> >> <cdfield.name>allArticlesInGroup</cdfield.name> >> <items.class>test.ojb.broker.Article</items.class> >> <inverse_fk_descriptor_ids>4</inverse_fk_descriptor_ids> >> </CollectionDescriptor> >> ... >> >>This descriptor contains the following info: >>- The class ProductGroup has a container attribute allArticlesInGroup.=20 >> The Java-type of this attribute is not declared. It maybe of type >>SomeType[],=20 >> Collection, or ManageableCollection. >>- The Items in this Container are of type Article >>- The Mapping of class Article has a attribute with id=3D"4" that holds= a=20 >> foreign key value idetifying the associated ProductGroup >> >>HTH, >> >>Thomas >> >> >>>-----Urspr=FCngliche Nachricht----- >>>Von: Leandro Rodrigo Saad Cruz [mailto:le...@ib...] >>>Gesendet: Freitag, 22. M=E4rz 2002 15:30 >>>An: obj...@li... >>>Betreff: [OJB-developers] Using CollectionDescriptor in repository.xml >>> >>> >>>Hi all. There is one thing I didn't understand from the docs about >>>association mapping >>>http://objectbridge.sourceforge.net/tutorial3.html#1-n >>> >>><CollectionDescriptor id=3D"1"> >>> <cdfield.name>collection</cdfield.name>=20 >>> ******* -> does this field must be present in repository.xml in >>>SomeCLASS ClassDescriptor ? or just be a field in SomeCLASS impl ? >>> >>> <items.class>SomeCLASS</items.class> >>> <inverse_fk_descriptor_ids>2</inverse_fk_descriptor_ids> >>></CollectionDescriptor> >>> >>>I keep getting exceptions like this : >>>Expcetion : java.util.NoSuchElementException >>>StackTrace: java.util.NoSuchElementException at >>>ojb.broker.accesslayer.RsIterator.next(RsIterator.java) at >>>ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery >>>(PersistenceBrokerImpl.java:931)at=20 >>>ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery >>>(PersistenceBrokerImpl.java:1000)at=20 >>>ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery >>>(PersistenceBrokerImpl.java:1093)at=20 >>>ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery >>>(PersistenceBrokerImpl.java:1080)at >>>.... >>> >>>that doesn't help me so much. >>> >>> >>>--=20 >>>Leandro Rodrigo Saad Cruz >>>IT - Inter Business Tecnologia e Servicos (IB) >>>http://www.ibnetwork.com.br >>> >>> >>>_______________________________________________ >>>Objectbridge-developers mailing list >>>Obj...@li... >>>https://lists.sourceforge.net/lists/listinfo/objectbridge-developers >>> >>> |