Re: transactions
Per Nyfelt <[email protected]>
| Newsgroups | gmane.comp.java.ozone.user |
|---|---|
| Organization | Resourcing Networks |
| Message-ID | <[email protected]> |
Hi,
Yes you are missing something. Ozone is not designed to be used the same way
you would use JDBC. This means among other things:
* No need to close connections
* Using declarative transaction handling when possible will simplify your code
You should be able to simplify your code to something as follows:
LocalDatabase db1;
db1.open("/path/db");
Foo foo1 = (Foo)db1.createObject(FooImpl.class.getName(),0,"foo");
foo1.setName("Foo 1");
foo1 = (Foo)db1.objectForName("foo");
System.out.println(foo1.getName()); // some operation of foo1
db1.close();
Best regards,
Per
tisdagen den 2 mars 2004 16.37 skrev Sunil Goyal:
> Hello leo,
>
> Thanks for sorting out some of the issues. Finally
> I have been able to run some code of my application:-)
>
> But one more issue still there :-)
> I am getting a stack overflow in a particular case.
> [java] got local db
> [java] WARN [main] Transaction - ta[id=5102,blocker=null]: uncaught
> exception: (java.lang.StackOverflowError)
> [java] java.lang.StackOverflowError
> [java] WARN [main] Transaction - ta[id=5102,blocker=null]: uncaught
> exception: (java.lang.StackOverflowError)
> [java] java.lang.StackOverflowError
> [java] java.lang.StackOverflowError
> [java] at
> org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:536)
> [java] at
> org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:485)
> [java] at
> org.ozoneDB.ExternalDatabase.objectForName(ExternalDatabase.java:760)
> [java] at
> org.cultos.ozstorage.mdwb.kdb.MdwbEmmoStorage.getRootEmmo(MdwbEmmoStorage.j
>ava:158)
>
>
>
> I am creating a LocalDatabase , putting an object and rertieving that
> object.
>
> LocalDatabase db1;
> db1.open("/path/db");
> ExternalTransaction tr1 = db1.newTransaction();
> tr1.begin();
> Foo foo1 = (Foo)db1.createObject(FooImpl.class.getName(),0,"foo");
> foo1.setName("Foo 1"); // some operation on foo1
>
> tr1.commit();
> db1.close(); // step_middle_1
>
> db1.open("/path/db"); // step_middle_2
> ExternalTransaction tr2 = db1.newTransaction();
> tr2.begin();
> foo1 = (Foo)db1.objectForName("foo"); // get an error here..., stack
> overflow
> System.out.println(foo1.getName()); // some operation of foo1
> tr2.commit();
> db1.close();
>
>
> Now suppose if I don't close or open the database in between
> (step_middle_1 and step_middle_2) and just commit and open another
> transaction, then things are fine.
>
> FooImpl and Foo are the classes with the defined Ozone interfaces
> for getting proxies.
>
> Am I missing or doing something wrong over here in the
> code above? Thanks in advance. This is the last one for the day!!
>
> Regards
> Sunil
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click