RE: [ojb-users] references
Brought to you by:
thma
From: Ebersole, S. <ste...@vi...> - 2002-05-20 12:47:43
|
Any ideas? ******************************************** Steve Ebersole IT Integration Engineer Vignette Corporation 512.741.4195 Visit http://www.vignette.com ******************************************** -----Original Message----- From: Ebersole, Steven [mailto:ste...@vi...] Sent: Wednesday, May 08, 2002 7:09 AM To: 'Thomas Mahler'; obj...@li... Subject: RE: [ojb-users] references Below is the exception I get. I appears that the exception occurs when trying to resolve the reference to parent company when that fk column is null. If I remove that reference descriptor, everything works. Query from class com.vignette.it.apps.dbapi.domain.CompanyDO where comp_id= ? [DEFAULT] WARN: Please define a public constructor for class com.vignette.it.apps.dbapi.domain.CompanyDO with the following signature: (java.lang.Integer, java.lang.String, java.lang.Integer). It must initialize the classes persistent attributes. This is recommended to increase performance but it's not mandatory! [ojb.broker.singlevm.PersistenceBrokerImpl] ERROR: expected type: class com.vignette.it.apps.dbapi.domain.CompanyDO [ojb.broker.accesslayer.RsIterator] ERROR: null java.lang.ArrayIndexOutOfBoundsException at ojb.broker.metadata.ClassDescriptor.getFieldDescriptorByIndex(ClassDescripto r.java:263) at ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors( ObjectReferenceDescriptor.java:242) at ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyValues(ObjectRefe renceDescriptor.java:264) at ojb.broker.singlevm.PersistenceBrokerImpl.getReferencedObject(PersistenceBro kerImpl.java:700) at ojb.broker.singlevm.PersistenceBrokerImpl.retrieveReferences(PersistenceBrok erImpl.java:517) at ojb.broker.accesslayer.RsIterator.getObjectFromResultSet(RsIterator.java:263 ) at ojb.broker.accesslayer.RsIterator.next(RsIterator.java:145) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:900) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:966) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:1054) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:1041) at TestOJBInstall.execute(TestOJBInstall.java:66) at TestOJBInstall.main(TestOJBInstall.java:53) java.util.NoSuchElementException at ojb.broker.accesslayer.RsIterator.next(RsIterator.java:154) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:900) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:966) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:1054) at ojb.broker.singlevm.PersistenceBrokerImpl.getCollectionByQuery(PersistenceBr okerImpl.java:1041) at TestOJBInstall.execute(TestOJBInstall.java:66) at TestOJBInstall.main(TestOJBIError occurred : java.util.NoSuchElementException nstall.java:53) ******************************************** Steve Ebersole IT Integration Engineer Vignette Corporation 512.741.4195 Visit http://www.vignette.com ******************************************** -----Original Message----- From: Thomas Mahler [mailto:tho...@ho...] Sent: Friday, May 03, 2002 12:11 AM To: Ebersole, Steven Subject: Re: [ojb-users] references Hi Steven, Ebersole, Steven wrote: > I am looking at switching from Castor over to OJB as it looks really > promising in terms of its functionality (I especially love the use of > virtual proxies here). I did have two questions come up from my initial > trials of OJB. > > 1) Is it necessary to have both the foreign key and the foreign reference > mapped and present on the object? depends on the navigibility between your persistent classes. If you want to navigate from the 1-side to the n-side only, you just need a foreign key (and a ForeignKeyDescriptor). If you want navigation from the n-side to the 1-side too, you'll also need a reference attribute (and a ReferenceDecsriptor too). In the examples, the relation between > Article and ProductGroup is the example From which I was working. There, > Article has two attributes dealing with its relation to a ProductGroup, Yes, because we have navigation from ProductGroup to all its Articles and from an Article to its associated ProductGroup. > productGroupId (which is the DB fk field) and productGroup (which is an > instance of the ProductGroup object to which productGroupId referes). Is it > necessary to do this, or is there a way to have the Product object only know > about its related ProductGroup? No, because ProductGroup and Article have a 1:n relation the table representaing Article entities *must* have a foreign key to identify the associated ProductGroup. > > 2) I mapped a relationship, uing my classes, similiar to the above > relationship (it is a company -> parent company relationship). However, I > get exceptions if a particular company did not have a parent company (its > PRTN_COMP_ID column on the DB is NULL). Is there something additional I > have to set up in the mapping to define that side of the relationship as > optional? Below is the mapping I have for this: > > > <ClassDescriptor id="2"> > <class.name>com.vignette.it.apps.dbapi.domain.CompanyDO</class.name> > <table.name>COMPANY</table.name> > <FieldDescriptor id="1"> > <field.name>id</field.name> > <column.name>COMP_ID</column.name> > <jdbc_type>INTEGER</jdbc_type> > <PrimaryKey>true</PrimaryKey> > </FieldDescriptor> > ... > <FieldDescriptor id="5"> > <field.name>parentCompanyId</field.name> > <column.name>PRNT_COMP_ID</column.name> > <jdbc_type>INTEGER</jdbc_type> > </FieldDescriptor> > <ReferenceDescriptor id="1"> > <rdfield.name>parentCompany</rdfield.name> > > <referenced.class>com.vignette.it.apps.dbapi.domain.CompanyDO</referenced.cl > ass> > <fk_descriptor_ids>5</fk_descriptor_ids> > </ReferenceDescriptor> > </ClassDescriptor> > Your mapping seems OK. This must be an OJB bug! Can you provide me with a full stacktrace ? thanks, Thomas > > Thanks > > > > > ******************************************** > Steve Ebersole > IT Integration Engineer > Vignette Corporation > 512.741.4195 > > Visit http://www.vignette.com > > ******************************************** > > _______________________________________________________________ > > Have big pipes? SourceForge.net is looking for download mirrors. We supply > the hardware. You get the recognition. Email Us: ban...@so... > _______________________________________________ > Objectbridge-users mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-users > > > > _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: ban...@so... _______________________________________________ Objectbridge-users mailing list Obj...@li... https://lists.sourceforge.net/lists/listinfo/objectbridge-users |