[odb-users] query results not being cached?
crburton at tnsi.com
Tue Jun 5 13:21:24 EDT 2012
Hi ODB Users,
I am not able to call "size()" on query results even if I try to use the "cache()" method on the results template. Here's the code snippet:
auto_ptr<database> ora_db (create_database (argc, argv));
transaction t (ora_db->begin());
MyPersistentClass *n = new MyPersistentClass (i);
cout << "About to call query..." << endl;
query pred (query:: name == n->name());
result r (ora_db->query<MyPersistentClass> (pred) );
cout << "...back." << endl;
if ( r.empty() == true )
cout << "no instances found..." << endl;
cout << "Query returned " << r.size() << " elements." << endl;
catch (const odb::exception& e)
cerr << e.what () << endl;
This is the output:
About to call query...
no instances found...
Query returned query result is not cached
So, r.empty() works, but r.size() does not. Is it possible to examine the size/count of the query result without iterating over it?
Thanks in advance,
This e-mail message is for the sole use of the intended recipient(s)and may
contain confidential and privileged information of Transaction Network Services.
Any unauthorised review, use, disclosure or distribution is prohibited. If you
are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.
More information about the odb-users