[odb-users] querying with relationships
Simón Emmanuel Gutiérrez Brida
simon.gutierrez.brida at gmail.com
Thu Jan 30 14:35:46 EST 2014
Thanks, this should work. I was going to make something like you suggested
in [1] but I didn't think it was necessary.
After trying the code, I have this problems:
if I declare the user field of Pattern like this
#pragma db not_null
std::tr1::weak_ptr<User> user;
Then I have an already persistent when I do
persist(user);
persist(pattern);
if I declare the user field of Pattern like this
#pragma db not_null
std::tr1::shared_ptr<User> user;
I have no persist problems but now when I make a query to retrieve all
users and store them in a vector<User> the push_back hangs in a odb
load method
2014-01-30 Boris Kolpackov <boris at codesynthesis.com>
> Hi Simón Emmanuel,
>
> Simón Emmanuel Gutiérrez Brida <simon.gutierrez.brida at gmail.com> writes:
>
> > I want to do a query like, get all patterns p from user such that
> > user.id== user_id and p.category == cattegory.
>
> Given the changes to your relationship that I suggested in my previous
> reply[1], here is how we can do this:
>
> typedef odb::query<Category> CategoryQuery;
>
> db.query<Category> (CategoryQuery::user->id == user_id &&
> CategoryQuery::category == category);
>
> [1] http://codesynthesis.com/pipermail/odb-users/2014-January/001758.html
>
> Boris
>
More information about the odb-users
mailing list