How to use Transaction

Apr 14, 2013 at 4:00 AM
Edited Apr 14, 2013 at 4:06 AM
Well, it looks greate and really easy to use. But I still met some problem in Transactions.
( Well, as a Chinese, my English is poor too... So please excuse my confusing essay... )

1:
After I did some operation and rollbacked it, I found the database become invalid :
var a = new ClassA() { Sth = 101 };
fac.Store(a);
fac.Rollback();
fac.Store( new ClassA() { Sth = 102 } ); // throw "NDatabase has thrown an Exception Error:1005:ODB session has been rollbacked (@1)"
What's is the correct way to use Transaction?

2:
Is there any way to use several transactions in the same time?
I found the API in IOdb about transactions are just method Commit and Rollback. So is it possible to use several transactions in the same time?
( I'm sorry I didn't do any tries because of the problem 1 )

Thanks!
Coordinator
Apr 14, 2013 at 5:47 PM
Hello,
here you have a documentation page about transactions - please make sure you refreshed the page (so you see the example code there - cached old version doesn't have it).

Ad1:
yes, after rollback you need to reopen NDatabase (OdbFactory.Open) for now, if you will try to store something after rollback, the OdbRuntimeException will be thrown. If there is any reason why that should be changed, pls add the ticket in Issue Tracker.

Ad2.
Nope, NDatabase supports only one opened transaction.

Thanks,
Jacek
Apr 18, 2013 at 4:19 AM
On, really thanks!
And, I hope those problem (especially Ad1) may get improved, you know, reopen a database need lots of resource.
Really thanks!