Re: JDO and associations (1:n, m:n)
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- 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
JDO : Unable to update object with references
I know I have already posted about this but it is very annoying and I have been stuck to this problem for one week... I create an instance of Company. I make it persistent : ok, my DB get it perfectly. I create a Division for my instance of Company. I make it persistent and everything goes well too. I begin a transaction. I retrieve my instance of Company. I change its name and I commit and at this point I get this : [JDO] DEBUG: OjbStoreManager.flush: company.business.Division{1}, P_NEW [JDO] DEBUG: OjbStoreManager.insert [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException during the execution of the insert (for a company.business.Division): Invalid argument value, message from server: Duplicate entry '1' for key 1 That is to say, OJB does not understand that this Division which is referenced by the modified Company only need to be updated and not inserted. How can I change it ? Any clue, advice, feeling, prayer welcome :) -- Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDO and associations (1:n, m:n)
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]
How JDO knows about my DB ?
Hi, I'm trying to get a simple application running with the jdo-api. I went through the .java generation, the .jdo and the repository.xml generation... Now, I want to enhance my persistent .class as described in the .jdo. But the process fails with a Timeout connection. In fact I have never explained to the jdori how to get in touch with my dbms (MySQL). Can you help me ? (of course you can ;) -- Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
JDO only work with Sun's jar (and not my own build)
Hi all, Since two days I couldn't get rid of this failure when in tutorial5 I tried to do whatever the program propose : The list of available products: [JDO] DEBUG: OjbStoreConnector.begin: connectionReadyForRelease=false java.lang.NoSuchFieldError: tokenTypeToASTClassMap at com.sun.jdori.common.query.jdoqlc.JDOQLParser.buildTokenTypeASTClassMap(Unknown Source) at com.sun.jdori.common.query.jdoqlc.JDOQLParser.init(Unknown Source) at com.sun.jdori.common.query.jdoqlc.JDOQLParser.init(Unknown Source) at com.sun.jdori.common.query.jdoqlc.JDOQLC.createStringParser(Unknown Source) at com.sun.jdori.common.query.jdoqlc.JDOQLC.setFilter(Unknown Source) at com.sun.jdori.common.query.QueryImpl.compile(Unknown Source) at com.sun.jdori.common.query.QueryImpl.execute(Unknown Source) at org.apache.ojb.tutorial5.UCListAllProducts.apply(UCListAllProducts.java:44) at org.apache.ojb.tutorial5.Application.run(Application.java:100) at org.apache.ojb.tutorial5.Application.main(Application.java:68) Cannot close PersistenceManager while transaction is still active. Now, it is solved, the problem came from my jdo jars : I built them myself from the JDORI sources. Now, I use the jars from java.sun.com and everything goes well but the mystery remains without any explanation : why ojb doesn't work with my jars ? -- Hubert - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]