You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by palmer_one <pa...@zoho.com> on 2013/07/18 05:13:37 UTC

how to Query POJO's, multiple tables(or multiple linked objects)

Hi Kasper,  I was in contact with you a few years ago. 
  I am trying to do things with the Jackcess API, but it does not allow one to 'push' relationships into a newly created database MDB file. It only allows to put tables and data. 
  So I created like 3 tables(POJO's) in memory that represent table entities, 2 tables and a join table that handles a Many-to-Many relationship or was it a one-to-many relationship. I would like to query this and get a Result-Set back and then push this into Access mdb as a result table. 
  SO the context is university courses. One has Faculty table, then the join table called Sections, and Courses table. 
  So if I query a particular professor from Faculty table I want to get related data, that is the courses 
   he/she teaches. 
   How do you use Meta-Model to query multi-tables(POJO objects)? 
  Hope you can help. 
  Regards, 
  P 
 



Re: how to Query POJO's, multiple tables(or multiple linked objects)

Posted by Kasper Sørensen <i....@gmail.com>.
I am glad to help :-) I just meant that everyone is invited to participate,
so adressing me will maybe exclude others from answering.

Regarding ORM ... The idea has been coming and going from time to time to
make an ORM on top of MetaModel. That would allow you to map Java beans to
e.g. Access, Excel spreadsheets or whatever. But it seems like something
that's worthy of it's own project, except if we limit it to something very
basic.


2013/7/18 palmer_one <pa...@zoho.com>

> OK,
> Did not know that addressing the specific person was not the way to do
> things.
>
> I just saw the example and it seems to have 2 objects
>
> "You could make a DataContext with both the 'persons' and 'titles'
> collections, and join them, like this:"
>
> This example is what I am looking for, because I can query some
> collections, get the result and then push this result into MS Access as a
> table.
>
> With Jackcess Library it does not allow for creating queries, not yet
> anyways.
> So one can create a a bunch of tables, but no way to set
> relationships/referential integrity and to query
> the linked entities.
>
> I believe the example provided can definitely help.
>
> When you mentioned ORM, it never occurred to me that maybe one can do this
> querying on POJO's using ORM.
> And recall that the Jackcess API unfortunately is not a JDBC driver, which
> means that direct interaction with ORM and Jackcess is not possible.
>
> P
>
>  ---- On Thu, 18 Jul 2013 00:40:55 -0700 Kasper Sø
> rensen&lt;i.am.kasper.sorensen@gmail.com&gt; wrote ----
> Hi Palmer,
>
> First I should say, please don't address questions like this to me
> individually. Although I am one of the lead people here, I am not the only
> one and especially with the move to Apache we want to spread knowledge a
> lot more.
>
> I am affraid you're not going to get much luck by using BOTH the access
> module and the pojo module. It sounds a bit like you think the pojo module
> is a ORM-like mapping module, but actually it is not. It is simply an
> in-memory collection based DataContext. It allows querying and updating an
> in-memory data structure as if it was a database - mostly used for
> mocking/testing etc. I just updated the wiki with this example (taken from
> the old website):
> https://wiki.apache.org/metamodel/examples/PojoDataContext
>
> So you should stick with the Access module only for your case. And probably
> discard the pojos that you mention.
>
> Does this answer your questions?
>
>
> 2013/7/18 palmer_one &lt;palmer_one@zoho.com&gt;
>
> &gt; Hi Kasper, I was in contact with you a few years ago.
> &gt; I am trying to do things with the Jackcess API, but it does not allow
> &gt; one to 'push' relationships into a newly created database MDB file.
> It only
> &gt; allows to put tables and data.
> &gt; So I created like 3 tables(POJO's) in memory that represent table
> &gt; entities, 2 tables and a join table that handles a Many-to-Many
> &gt; relationship or was it a one-to-many relationship. I would like to
> query
> &gt; this and get a Result-Set back and then push this into Access mdb as a
> &gt; result table.
> &gt; SO the context is university courses. One has Faculty table, then the
> &gt; join table called Sections, and Courses table.
> &gt; So if I query a particular professor from Faculty table I want to get
> &gt; related data, that is the courses
> &gt; he/she teaches.
> &gt; How do you use Meta-Model to query multi-tables(POJO objects)?
> &gt; Hope you can help.
> &gt; Regards,
> &gt; P
> &gt;
> &gt;
> &gt;
> &gt;
>
>
>

Re: how to Query POJO's, multiple tables(or multiple linked objects)

Posted by palmer_one <pa...@zoho.com>.
OK,
Did not know that addressing the specific person was not the way to do things.

I just saw the example and it seems to have 2 objects

"You could make a DataContext with both the 'persons' and 'titles' collections, and join them, like this:"

This example is what I am looking for, because I can query some collections, get the result and then push this result into MS Access as a table.

With Jackcess Library it does not allow for creating queries, not yet anyways.
So one can create a a bunch of tables, but no way to set relationships/referential integrity and to query
the linked entities.

I believe the example provided can definitely help.

When you mentioned ORM, it never occurred to me that maybe one can do this querying on POJO's using ORM.
And recall that the Jackcess API unfortunately is not a JDBC driver, which means that direct interaction with ORM and Jackcess is not possible.

P

 ---- On Thu, 18 Jul 2013 00:40:55 -0700 Kasper Sørensen&lt;i.am.kasper.sorensen@gmail.com&gt; wrote ---- 
Hi Palmer, 
 
First I should say, please don't address questions like this to me 
individually. Although I am one of the lead people here, I am not the only 
one and especially with the move to Apache we want to spread knowledge a 
lot more. 
 
I am affraid you're not going to get much luck by using BOTH the access 
module and the pojo module. It sounds a bit like you think the pojo module 
is a ORM-like mapping module, but actually it is not. It is simply an 
in-memory collection based DataContext. It allows querying and updating an 
in-memory data structure as if it was a database - mostly used for 
mocking/testing etc. I just updated the wiki with this example (taken from 
the old website): https://wiki.apache.org/metamodel/examples/PojoDataContext 
 
So you should stick with the Access module only for your case. And probably 
discard the pojos that you mention. 
 
Does this answer your questions? 
 
 
2013/7/18 palmer_one &lt;palmer_one@zoho.com&gt; 
 
&gt; Hi Kasper, I was in contact with you a few years ago. 
&gt; I am trying to do things with the Jackcess API, but it does not allow 
&gt; one to 'push' relationships into a newly created database MDB file. It only 
&gt; allows to put tables and data. 
&gt; So I created like 3 tables(POJO's) in memory that represent table 
&gt; entities, 2 tables and a join table that handles a Many-to-Many 
&gt; relationship or was it a one-to-many relationship. I would like to query 
&gt; this and get a Result-Set back and then push this into Access mdb as a 
&gt; result table. 
&gt; SO the context is university courses. One has Faculty table, then the 
&gt; join table called Sections, and Courses table. 
&gt; So if I query a particular professor from Faculty table I want to get 
&gt; related data, that is the courses 
&gt; he/she teaches. 
&gt; How do you use Meta-Model to query multi-tables(POJO objects)? 
&gt; Hope you can help. 
&gt; Regards, 
&gt; P 
&gt; 
&gt; 
&gt; 
&gt; 



Re: how to Query POJO's, multiple tables(or multiple linked objects)

Posted by Kasper Sørensen <i....@gmail.com>.
Hi Palmer,

First I should say, please don't address questions like this to me
individually. Although I am one of the lead people here, I am not the only
one and especially with the move to Apache we want to spread knowledge a
lot more.

I am affraid you're not going to get much luck by using BOTH the access
module and the pojo module. It sounds a bit like you think the pojo module
is a ORM-like mapping module, but actually it is not. It is simply an
in-memory collection based DataContext. It allows querying and updating an
in-memory data structure as if it was a database - mostly used for
mocking/testing etc. I just updated the wiki with this example (taken from
the old website): https://wiki.apache.org/metamodel/examples/PojoDataContext

So you should stick with the Access module only for your case. And probably
discard the pojos that you mention.

Does this answer your questions?


2013/7/18 palmer_one <pa...@zoho.com>

> Hi Kasper,  I was in contact with you a few years ago.
>   I am trying to do things with the Jackcess API, but it does not allow
> one to 'push' relationships into a newly created database MDB file. It only
> allows to put tables and data.
>   So I created like 3 tables(POJO's) in memory that represent table
> entities, 2 tables and a join table that handles a Many-to-Many
> relationship or was it a one-to-many relationship. I would like to query
> this and get a Result-Set back and then push this into Access mdb as a
> result table.
>   SO the context is university courses. One has Faculty table, then the
> join table called Sections, and Courses table.
>   So if I query a particular professor from Faculty table I want to get
> related data, that is the courses
>    he/she teaches.
>    How do you use Meta-Model to query multi-tables(POJO objects)?
>   Hope you can help.
>   Regards,
>   P
>
>
>
>