Ned, You are right, I had enough errors in this "simplified" test case that it was impossible to understand. My apologies.
In the process of developing a more thoughtful testcase, I realized my problem. I am loading multiple JDO objects, but the database names in the configuration file "<database name=...>" were the same. The second instance of JDO loaded with the same database name overwrote the existing mappings (I guess they are static). This make perfect sense. Thanks. -mark -----Original Message----- From: Ned Wolpert [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 12:06 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Creating multiple JDO objects with different mappings I'm afraid I don't understand what you're trying to do with this example. You seem to have four classes. ClassY, Y, ClassX, X Is this what you intended? I'll assume yes, where ClassX and ClassY are mapped to the database, and Y and X manipulate them. Is that correct? I'm going to assume that in your example you meant to do this: X x = new X("mappingX.xml"); x.doSomething(); Y y = new Y("mappingY.xml"); y.doSomething(); (Also, in your example, you had ClassY y = new ClassX("mappingY.xml"); which you may have meant ClassY y = new ClassY("mappingY.xml"); ) Forgive me if I misunderstand your problem, but your example wasn't clear enough for me. It seems like you are using classes that you have mapped to the database also as objects that contains JDO objects? Depending on the mapping of the file, this could be problematic. Try having X and Y be refered to in the mapping.xml file, and then create a class called ManipulateX and ManipulateY which take in the mapping.xml file, and return your X and Y objects. Perhaps you should forward your mapping.xml file, and your code segments rather than the format you used. On Tue, 2002-01-29 at 08:21, Mark Petrotta wrote: > Hello, > > I have a problem when I create multiple JDO objects in the same JVM > instance. > > Consider the following simplified code: > > > // Two classes defined that operate on persistent objects... > > class X { > JDO _jdo; > > X(String databaseFile) { > _jdo = new JDO(); > _jdo.loadConfiguration(new > java.io.File(databaseFile).toURL().toString()); > } > > doSomething() { > Database db = _jdo.getDatabase(); > db.begin(); > db.load(ClassX.class, someID); > ... > db.commit(); > } > } > > class Y { > JDO _jdo; > > Y(String databaseFile) { > _jdo = new JDO(); > _jdo.loadConfiguration(new > java.io.File(databaseFile).toURL().toString()); > } > > doSomething() { > Database db = _jdo.getDatabase(); > db.begin(); > db.load(ClassY.class, someID); > ... > db.commit(); > } > } > > ClassX x = new ClassX("mappingX.xml"); > x.doSomething(); > > ClassY y = new ClassX("mappingY.xml"); > y.doSomething(); > > > If I run the code, I get the following error when y.doSomething() is called. > > org.exolab.castor.jdo.ClassNotPersistenceCapableException: The class ClassY > is not persistence capable: no mapping was defined for the class > > If I change the order, so that ClassY is constructed and run first, then > x.doSomething() will give me the same error > > org.exolab.castor.jdo.ClassNotPersistenceCapableException: The class ClassX > is not persistence capable: no mapping was defined for the class > > Both of these will run fine if run seperately (in seperate JVMs). > > It would seem that the JDO object is maintaining static mapping information > that gets overwritten. Any comments? > > -mark > > ----------------------------------------------------------- > If you wish to unsubscribe from this mailing, send mail to > [EMAIL PROTECTED] with a subject of: > unsubscribe castor-dev -- Virtually, Ned Wolpert <[EMAIL PROTECTED]> D08C2F45: 28E7 56CB 58AC C622 5A51 3C42 8B2B 2739 D08C 2F45 ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
