[Dbo] fatal error: Operation requires an active transaction
Added by Vincenzo Romano over 11 years ago
It sounds weird to me. Anyway, this is my code snippet:
backend::Postgres db( string( "dbname=adb user=auser" ) );
session.setConnection( db );
session.mapClass<Event>("events");
fprintf( stderr,"\n***SESSION IS READY!\n" );
int count = session.query<int>("select count(1) from events"); // This query works in my PG db!
fprintf( stderr,"\n***COUNT:%d\n",count );
And this is the error I consistently get:
[2014-May-01 11:57:44.792021] 2846 [/ NmP5Q8FfNnhUA4qX] [info] "WEnvironment: UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
127.0.0.1 - - [2014-May-01 11:57:44.792709] "GET / HTTP/1.1" 200 2168
[2014-May-01 11:57:44.792746] 2846 - [info] "WebRequest: took 0.917ms"
***SESSION IS READY!
[2014-May-01 11:57:44.837177] 2846 [/ NmP5Q8FfNnhUA4qX] [error] "Wt: fatal error: Operation requires an active transaction"
[2014-May-01 11:57:44.837239] 2846 [/ NmP5Q8FfNnhUA4qX] [info] "Wt: session destroyed (#sessions = 0)"
If I uncomment last two lines everything works fine (but then I am not doing any access to the database at all!).
Of course I think I am missing something, but the Dbo documentation seems not to be of any help to me.
Any hint?
Replies (2)
RE: [Dbo] fatal error: Operation requires an active transaction - Added by Koen Deforche over 11 years ago
Hey,
You need a transaction, even all you do is read (because depending on transaction isolation, there still may be consistency that needs to be guaranteed for multiple queries within a transaction).
Regards,
koen
RE: [Dbo] fatal error: Operation requires an active transaction - Added by Vincenzo Romano over 11 years ago
I've got it now.
I would suggest to make this more clear in the Dbo tutorial.
You get an example at chapet 7.6 and details only at chapter 8, while you show actual Dbo code since the very beginning.
Anyway, I admit my bad for bot having browsed the whole page to the end...
Thanks a lot.