RE: [ojb-users] references
Brought to you by:
thma
From: Ted S. <emo...@ya...> - 2002-05-29 10:51:05
|
Hi Steven, I recently ported an application of mine from Castor to OJB and am glad I did. However, I also had problems getting things to work at first. I spent a lot of time stepping through OJB with a debugger just to find out that it was my fault, I didn't read the docs carefully enough. Anyway, one BIG THING you can do diagnose problems (and I don't know if this is in the docs or not) is to crank up the logging that OJB does. In your ojb.properties file look for this line... ojb.broker.metadata.RepositoryXmlHandler.LogLevel=WARN ...and change it to this... ojb.broker.metadata.RepositoryXmlHandler.LogLevel=DEBUG Doing that will make it easier to see if there are syntax problems in your mapping file. Also, you can change this line... ojb.broker.accesslayer.SqlGenerator.LogLevel=WARN ...to this... ojb.broker.accesslayer.SqlGenerator.LogLevel=DEBUG ...and this will make it easier to see if you've misspelled and DB table or column names or to see how well the mapping is working. ted stockwell --- "Ebersole, Steven" <ste...@vi...> wrote: > Trying not to sound pushy here, but as I mentioned in my first post I > am > considering moving from Castor over to OJB for the project on which I > am > currently working. However, I am unable to get even simple reference > relationships working. Obviously I can't move the project over to > this > library if this is going to be the case. But it seems others are > getting > this to work. > > So I guess my question is now, should I even continue evaluating OJB? > I > mean it has been almost a month since my original post, and I am > still no > closer to solving the issue and not a single person has been willing > (or > knowledgeable enough) to help. I know this is open source and as > such: 1) I > could simply debug the library myself; 2) people contribute and help > others > as their time allows. As for one, I am in the middle of a project > myself > and unfortunately cannot validate the time to spend troubleshooting a > proposed library which may not even be used. As for two, I > understand the > time constraints of others, but to wait one month for for a response > on such > a basic O/R-mapping requirement as relationships? > > Also, as I have previously mentioned, the set-up and the > implementation of > this library are extremely promising (especially in the environment > in which > I was hoping to use it). In short I want to use this product. > However, I > cannot swap out Castor to OJB at this time because I do not feel > confident > enough in OJB's capibilities mainly because every test I have tried > to run > (above and beyond strict table-to-object) fails. > > Please, please can anyone help with the below problem? Anyone > encountered > it before? > > Thanks in advance > > > > ******************************************** > Steve Ebersole > IT Integration Engineer > Vignette Corporation > 512.741.4195 > > Visit http://www.vignette.com > > ******************************************** > > > -----Original Message----- > From: Ebersole, Steven [mailto:ste...@vi...] > Sent: Monday, May 20, 2002 7:47 AM > To: 'Thomas Mahler'; obj...@li... > Subject: RE: [ojb-users] references > > > 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 > > _______________________________________________________________ > Hundreds of nodes, one monster rendering program. > Now that's a super model! Visit http://clustering.foundries.sf.net/ > > _______________________________________________ > Objectbridge-users mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-users > > _______________________________________________________________ > > Don't miss the 2002 Sprint PCS Application Developer's Conference > August 25-28 in Las Vegas -- > http://devcon.sprintpcs.com/adp/index.cfm > > _______________________________________________ > Objectbridge-users mailing list > Obj...@li... > https://lists.sourceforge.net/lists/listinfo/objectbridge-users __________________________________________________ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com |