[Dbixx-devel] Questions about DatabaseInterface (again)
Status: Alpha
Brought to you by:
cyborch
From: Jerry S. <ye...@sp...> - 2002-06-16 15:59:12
|
Hello again, I have a basic MySQLDatabaseInterface class going. It can retrieve simple objects from the database and store them to the database. I haven't worked on multiple table support yet. A couple of questions have arisen out of this: 1. PersistentFactory.createPersistent(DatabaseInterface dbi, Object identifier) In my implementation of the PersistentFactory interface I have been using identifier to pass in a string that tells the Factory which record to retrieve from the database. It happens to be a String object and in the Factory I just use the toString() method on the object to use the String in my search. Is this the way it was intended to be used? Is the usage of the Object being passed in something that the implementor of the PersistentFactory interface and the user of it have to agree on? 2. PersistentFactory did not have a storePersistent() method like the diagrams indicate. I added: storePersistent(DatabaseInterface dbi, Persistent p) Sound about right? 3. When storing an object to the database, I don't know when to use an UPDATE statement and when to use an INSERT statement. If the object was retrieved from the database, modified and is now to be put back into the database, an UPDATE statement should be used. If it is a brand new object then an INSERT statement should be used. How do you tell which one the object is? Running another query just to find out if the object is in the database seems wasteful and if the database allows multiple non-unique records then this method would not work. It seems to me that the Factory needs to have control over which type of statement is run. Thoughts? I'm close to getting the code in a contributable state. How do you want it submitted? Jerry |