[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Update a Ozone Object/Transactions



On Sat, 16 Sep 2000, Saravanan Bellan wrote:
> What is the difference between explicit and implicit transaction?. From the
> names I could guess that it is by default implicit, where changes are
> autocommited.
Yes, you are right. "explicite transactions" means "explicite transaction
demarcation". By default every method call from the client to the server is
wrapped in a transaction. But it is also  possible to explicitely define
transction begin/commit/abort. This is what you did in your example code.

> 
> Following is the code I'm trying, but the change I make(pDoc.createComment)
> does get reflected in the database.
What do you expect? After tx.commit the changes get reflected in the db. What's
wrong with this? I'm sure I miss something here.


Falko


> 
> What is wrong here?
> 
> import org.w3c.dom.Document;
> 
> import org.ozoneDB.ExternalTransaction;
> import org.ozoneDB.ExternalDatabase;
> import org.ozoneDB.RemoteDatabase;
> 
> public final class Trans {
> 
>     public static void main (String args[]) {
> 
>         ExternalDatabase database;
>         Document         pDoc;
>         String           docName = null;
> 
>         System.out.println ("Modify document: " + docName);
> 
>         try  {
>             database = new RemoteDatabase();
>             ((RemoteDatabase)database).open ("localhost", 3333);
> 
>             database.reloadClasses ();
> 
>             pDoc = (Document) database.objectForName ("test.xml");
> 
>             ExternalTransaction tx = database.newTransaction();
>             tx.begin();
>             pDoc.createComment("This is my COmment"); //Not Working
>             tx.commit();
>             database.close();
>             }
>         catch (Exception except) {
>             except.printStackTrace ();
>             }
>         }
>     }
> 
> Thanks,
> -Sarva
> 
> -----Original Message-----
> From: Falko Braeutigam [mailto:falko@smb-tec.com]
> Sent: Friday, September 15, 2000 8:43 AM
> To: Saravanan Bellan; 'ozone-users@ozone-db.org'
> Subject: Re: Update a Ozone Object
> 
> 
> On Fri, 15 Sep 2000, Saravanan Bellan wrote:
> > This could be a dumb question, but how do you update a XML document object
> > stored in Ozone. I see methods for creating, deleting, copying but no
> > update.
> > 
> > All I want to do is,
> > 
> > Database Open
> > doc = Database , ObjectForName
> > Use DOM API to make some changes on doc
> > Submit doc.
> 
> Well, ozone's DOM is _inherently_ persistent: just commit the transaction
> and
> all your changes are reflected in the database. This does not just work
> for DOM this works for all kind of objects stored in ozone. This is the
> architecture of ozone and this makes up its actual power.
> 
> Excuse this somewhat emotional answer ;) But it sometimes seemes to me that
> this
> very basic point of ozone is not well known. Or am I wrong here?
> 
> 
> Falko
> -- 
> ______________________________________________________________________
> Falko Braeutigam                              mailto:falko@smb-tec.com
> SMB GmbH                                        http://www.smb-tec.com
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com