[odb-users] Question about sessions

Javier Gutierrez javier.gutierrez at web.de
Mon Nov 13 04:10:32 EST 2023


Hi Boris,

As I understand when using persist(), load(), find() or loaded by query the
session-enabled object's pointer is stored in the session.
Can you confirm if following works?

    person p ("John", "Doe"); 		// Does this need to be a pointer in
order to work?
    session s;
    transaction t (db.begin ());
    unsigned long id (db.persist (p))	// p is cached in s.
    t.commit ();

    //

    typedef odb::query<person> query;
    typedef odb::result<person> result;
    query q (query::first == "John" && query::last == "Doe");
    result r (db.query<person> (q)); 	// Does this retrieve from session?

Additionally, is there a way to check how many objects are stored in the
session (using the out of the box session class) ?

Thanks in advance.

Best regards,
Javier Gutierrez




More information about the odb-users mailing list