> Christian,
> 
> Have you tried specifying the key generator only on the Person
> object and not on the Kunde object?
> 
> Bruce


Thanks for your help, Bruce. It now is working :)
But as I solved this problem, I got another one instead...

I've got a Class, that has all methods I need to store and load objects from
the Database.
It looks roughly like this:

// BEGIN CLASS
public class DbBackend {

  private Logger logger = null;
  private JDO jdo = null;
  private Database database = null;
  
  public IR_Datenbank(String xmlDbSchema, String dbName) throws Exception {
    jdo = new JDO(dbName);
    jdo.setConfiguration(xmlDbSchema);
    jdo.setDatabaseName(dbName);
    database = jdo.getDatabase();
    database.setAutoStore(true);
  }
  
  public void insertObject(Object object) throws Exception {
    database.begin();
    database.create(object);
    database.commit();
  }

}
// END CLASS


And I've written a Test class, to test, if I can insert, update and load
objects from the database.
In this class, I execute this code:

  // Create a Kunde object
  Kunde kunde = createTestKunde();

  // Database backend
  DbBacken backend = new DbBackend("src/jvfa/test/database.xml", "jvfa");

  // Insert the kunde into the database
  backend.insertObject(kunde);


That works fine. The Kunde object gets perfectly written to the database.
But now it comes. When I try to access the fields of my kunde-object 
(e.g. to find out what ID was generated by the key-generator) after
the insert, I got an Exception. I've debugged it, and found out, that
a DataObjectAccessException is thrown in TransactionContext.create().

I simply added after "backend.insertObject(kunde)" the following line :

  System.out.println("Generated ID:");
  System.out.println(kunde.getId());

And then I got the exception. The most curious thing is:
I've set a breakpoint after the insertObject() method. But he never arrives
there.
Even the System.out.println("Generated ID:") is not executed.

My Idea is, that the database.create() method is threaded and the code is
executed at the
same time. So Castor has a lock on the Kunde object that protects access on
it. 
What do I have to do, that the insertObject() method waits until Castor has
finished it's
transaction and I can access the Kunde object.


Thanks for your help and sorry for my bad English,
Christian

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to