Hi Thomas, Thank you for your answer, here is my XML ClassDescriptor :
-------------- <class-descriptor class="company.business.Division" table="Division"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="name" column="name" jdbc-type="VARCHAR"/> <field-descriptor name="companyId" column="companyId" jdbc-type="INTEGER"/> <field-descriptor name="superDivisionId" column="superDivisionId" jdbc-type="INTEGER"/> <reference-descriptor name="company" class-ref="company.business.Company"> <foreignkey field-ref="companyId"/> </reference-descriptor> <reference-descriptor name="superDivision" class-ref="company.business.Division"> <foreignkey field-ref="superDivisionId"/> </reference-descriptor> <collection-descriptor name="subDivisions" element-class-ref="company.business.Division" orderby="id" sort="DESC"> <inverse-foreignkey field-ref="superDivisionId"/> </collection-descriptor> </class-descriptor> <class-descriptor class="company.business.Building" table="Building"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="name" column="name" jdbc-type="VARCHAR"/> <collection-descriptor name="companies" element-class-ref="company.business.Company" indirection-table="Building_Company"> <fk-pointing-to-this-class column="buildingId"/> <fk-pointing-to-element-class column="companyId"/> </collection-descriptor> </class-descriptor> <class-descriptor class="company.business.Company" table="Company"> <field-descriptor name="id" column="id" jdbc-type="INTEGER" primarykey="true" autoincrement="true"/> <field-descriptor name="name" column="name" jdbc-type="VARCHAR"/> <collection-descriptor name="divisions" element-class-ref="company.business.Division"> <inverse-foreignkey field-ref="companyId"/> </collection-descriptor> <collection-descriptor name="buildings" element-class-ref="company.business.Building" indirection-table="Building_Company"> <fk-pointing-to-this-class column="companyId"/> <fk-pointing-to-element-class column="buildingId"/> </collection-descriptor> </class-descriptor> ------------------------------------ As you can see, these are the class descriptors of the application I spoke about in my last post. I hope you'll find something wrong (but in fact, because I read that for JDO all the auto-XXXX attributed have to be kept as default, I don't mention them in my repository_user.xml). Thank you again. -- Hubert Le samedi 24 janvier 2004 à 12h11, Thomas Mahler a écrit : > Hi Hubert, > > Please post the xml ClassDescriptors of your classes. I could imagine > that there is some trouble with the auto-update attributes of your > reference- and/or collection-descriptors > > Thomas > > Hubert Behaghel wrote: > >Hi there, > > > >I am trying to make a miniframework with OJB, based on its JDO plugin, > >so has to have business classes being persistent (almost transparently) > >and having a small application letting the user play with those > >persistent classes while viewing the state of the DB. (To be clear I try > >to have a very simple code for pedagogical purpose : this is like > >tutorial5 except that the class isn't Product but a set of classes > >generated from an UML diagram). > > > >All the basical operations work well but one : I can list, delete, > >insert objects but I cannot edit them... More precisely I can't edit > >them when they have references to other persistent objects. > > > >How do I proceed to edit one object ? I tried many ways :) > > > >First, my idea was to ask the user the id of the object (or everything > >which let me identify the one he wants), to get it from the database, > >and to modify a copy of it. Then when this is done, I begin a > >transaction, copy all the fields from the up-to-date copy to the > >original persistent instance (even the unmodified fiels) and commit. The > >problem is : the instance itself is updated correctly but the references > >are attempted to be reinserted automatically (even if unmodified) > >causing the database to reject it. As a matter of fact, those references > >have already been inserted so inserted them again is impossible : they > >share the same primary key (id). > > > >The second idea was to simply delete and then insert the copy after > >giving it the id of the deleted object. Here I got a JDOUserException > >for trying to insert an object with a key that already exist in the > >Persistence Manager cache... (does it means that JDO has got its own > >cache ? is this cache unable to "see" that the object was deleted just > >before ?) > > > >Then, I tried the tutorial-like way : that is to say to begin a > >transaction, get the object after getting the id from the user, let the > >user do what he wants with its fields and commit. This time, I got the > >same error as in the first procedure but quicker (so, is it a progress ? > >;) ) : in fact, when I reach the commit, the first thing that happen is > >that my persistent layer wants to insert the references that my instance > >has, but as ever, because they already are in the datastore, it is > >impossible... > > > >So what ? Give up with editing what I stored and simply show how to > >insert and delete ? :) > > > >Thank you in advance. > > > >-- > >Hubert > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: [EMAIL PROTECTED] > >For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]