[odb-users] Querying on Containers

Lukas Obermann obermann.lukas at gmail.com
Fri Oct 7 10:55:11 EDT 2016


Hi Boris,

thank you. But maybe you can help me out with the view, as I also have some
issues creating it.

So, lets assume following classes:

class main
{
  odb::lazy_shared_ptr<ClassA> ptr_a;
  std::vector< odb::lazy_shared_ptr<ClassA> > list_a;
  std::vector< odb::lazy_shared_ptr<ClassB> > ptr_b
}

class ClassA
{
  std::string iNeedToBeQueried;
}

class ClassB
{
  std::string iNeedToBeQueried;
  odb::lazy_shared_ptr<ClassC> ptr_c;
}

class ClassC
{
  std::string iNeedToBeQueried;
}

So, ptr_a is no issue, but I am not able to figure out how to add the two
vectors to the view and also access ClassC, all at the same time.
Those 3 cases are basically all the cases I have in that class i try to
query. Is this doable via a View or do I have to fallback to native queries?

Thanks,
Lukas

Boris Kolpackov <boris at codesynthesis.com> schrieb am Fr., 7. Okt. 2016 um
16:34 Uhr:

> Hi Lukas,
>
> Lukas Obermann <obermann.lukas at gmail.com> writes:
>
> > is it still true that querying on containers directly (without a view on
> > top) is not possible?
>
> Yes, that's true.
>
>
> > Asking cause I have a object with ~10 containers and I imagine it not
> > very efficient creating a view that basically "unwinds"/"projects" all
> > those containers so that a object can be loaded in one query.
>
> If you create such as view, you don't have to load the container columns
> as part of it (i.e., you would use the container columns in the JOIN/WHERE
> clauses only).
>
> Boris
>


More information about the odb-users mailing list