[odb-users] callback is not being called
Boris Kolpackov
boris at codesynthesis.com
Fri Oct 5 05:13:07 EDT 2012
Hi Doug,
Doug Tomm <dctomm at gmail.com> writes:
> i have defined a class with a persist callback, but that callback
> is not being called, for any event. everything works -- when i
> persist the object instance, it appears in the database. but
> except that the callback is never invoked.
>
> void oninsert(::odb::callback_event event, ::odb::database& db)
You need to make it const:
void oninsert(::odb::callback_event event, ::odb::database& db) const
Quoting the manual (Section 12.1.7, "callback"):
"The callback function for the *_persist, *_update, and *_erase events is
always called on the constant object reference while for the *_load events —
always on the unrestricted reference.
If only the non-const version of the callback function is provided, then only
the *_load events will be delivered. If only the const version is provided,
then all the events will be delivered to this function. Finally, if both
versions are provided, then the *_load events will be delivered to the
non-const version while all others — to the const version."
Boris
More information about the odb-users
mailing list