Quantcast

additional queries and associations

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

additional queries and associations

Trenton D. Adams
Hello,

I'd like to know if mybatis has functionality that will allow me to
make additional queries, based on data results from a primary query,
and do something similar to what associations do.

For example, I have a set of objects that go like this...

exam request
  - student
    - list of telephone numbers
    - list of address
    - list of emails
  - invigilator
    - list of telephone numbers
    - list of address
    - list of emails

Rather than creating one monolithic query, I'd like to have one query
for each of the following, but still have them put into the Java class
tree listed above.  I understand that this will take longer to query,
as it would need to hit the database multiple times, but it's far
easier to debug, and maintain.

- person
- telephone numbers for person
- addresses for person
- emails for person

Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Eduardo Macarron
Discriminator should let you do it.
http://www.mybatis.org/core/sqlmap-xml.html

On 3 feb, 20:02, Trenton <[hidden email]> wrote:

> Hello,
>
> I'd like to know if mybatis has functionality that will allow me to
> make additional queries, based on data results from a primary query,
> and do something similar to what associations do.
>
> For example, I have a set of objects that go like this...
>
> exam request
>   - student
>     - list of telephone numbers
>     - list of address
>     - list of emails
>   - invigilator
>     - list of telephone numbers
>     - list of address
>     - list of emails
>
> Rather than creating one monolithic query, I'd like to have one query
> for each of the following, but still have them put into the Java class
> tree listed above.  I understand that this will take longer to query,
> as it would need to hit the database multiple times, but it's far
> easier to debug, and maintain.
>
> - person
> - telephone numbers for person
> - addresses for person
> - emails for person
>
> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
I'll try that on Monday, when I get back to work, but that doesn't
look like what I need.  It appears, based on the documentation, that
it can simply apply another ResultMap to parts of the result, based on
what a certain value is in that result.  It doesn't appear that it can
apply an entirely new select though.

On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:

> Discriminator should let you do it.
> http://www.mybatis.org/core/sqlmap-xml.html
>
> On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>> Hello,
>>
>> I'd like to know if mybatis has functionality that will allow me to
>> make additional queries, based on data results from a primary query,
>> and do something similar to what associations do.
>>
>> For example, I have a set of objects that go like this...
>>
>> exam request
>>   - student
>>     - list of telephone numbers
>>     - list of address
>>     - list of emails
>>   - invigilator
>>     - list of telephone numbers
>>     - list of address
>>     - list of emails
>>
>> Rather than creating one monolithic query, I'd like to have one query
>> for each of the following, but still have them put into the Java class
>> tree listed above.  I understand that this will take longer to query,
>> as it would need to hit the database multiple times, but it's far
>> easier to debug, and maintain.
>>
>> - person
>> - telephone numbers for person
>> - addresses for person
>> - emails for person
>>
>> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Eduardo Macarron
All the mapping is done in resultmaps, event nested selects are on
them.

Try it and let us know how it went.

On 5 feb, 06:06, "Trenton D. Adams" <[hidden email]> wrote:

> I'll try that on Monday, when I get back to work, but that doesn't
> look like what I need.  It appears, based on the documentation, that
> it can simply apply another ResultMap to parts of the result, based on
> what a certain value is in that result.  It doesn't appear that it can
> apply an entirely new select though.
>
>
>
>
>
>
>
> On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:
> > Discriminator should let you do it.
> >http://www.mybatis.org/core/sqlmap-xml.html
>
> > On 3 feb, 20:02, Trenton <[hidden email]> wrote:
> >> Hello,
>
> >> I'd like to know if mybatis has functionality that will allow me to
> >> make additional queries, based on data results from a primary query,
> >> and do something similar to what associations do.
>
> >> For example, I have a set of objects that go like this...
>
> >> exam request
> >>   - student
> >>     - list of telephone numbers
> >>     - list of address
> >>     - list of emails
> >>   - invigilator
> >>     - list of telephone numbers
> >>     - list of address
> >>     - list of emails
>
> >> Rather than creating one monolithic query, I'd like to have one query
> >> for each of the following, but still have them put into the Java class
> >> tree listed above.  I understand that this will take longer to query,
> >> as it would need to hit the database multiple times, but it's far
> >> easier to debug, and maintain.
>
> >> - person
> >> - telephone numbers for person
> >> - addresses for person
> >> - emails for person
>
> >> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
In reply to this post by Eduardo Macarron
discriminator is not coming up in my auto-complete.  I cannot find any
example on the mybatis sites that would show which dtd or schema I
should be using.  I'm currently using the following.  Any ideas?

<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:

> Discriminator should let you do it.
> http://www.mybatis.org/core/sqlmap-xml.html
>
> On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>> Hello,
>>
>> I'd like to know if mybatis has functionality that will allow me to
>> make additional queries, based on data results from a primary query,
>> and do something similar to what associations do.
>>
>> For example, I have a set of objects that go like this...
>>
>> exam request
>>   - student
>>     - list of telephone numbers
>>     - list of address
>>     - list of emails
>>   - invigilator
>>     - list of telephone numbers
>>     - list of address
>>     - list of emails
>>
>> Rather than creating one monolithic query, I'd like to have one query
>> for each of the following, but still have them put into the Java class
>> tree listed above.  I understand that this will take longer to query,
>> as it would need to hit the database multiple times, but it's far
>> easier to debug, and maintain.
>>
>> - person
>> - telephone numbers for person
>> - addresses for person
>> - emails for person
>>
>> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
Never mind, the dtd url appeared red in my IDE, so I asked the IDE to
download it.  I guess it was probably using an old cached version,
which allowed it to auto-complete other elements.

On Mon, Feb 6, 2012 at 10:17 AM, Trenton D. Adams
<[hidden email]> wrote:

> discriminator is not coming up in my auto-complete.  I cannot find any
> example on the mybatis sites that would show which dtd or schema I
> should be using.  I'm currently using the following.  Any ideas?
>
> <!DOCTYPE mapper
>    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
>    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
>
> On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:
>> Discriminator should let you do it.
>> http://www.mybatis.org/core/sqlmap-xml.html
>>
>> On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>>> Hello,
>>>
>>> I'd like to know if mybatis has functionality that will allow me to
>>> make additional queries, based on data results from a primary query,
>>> and do something similar to what associations do.
>>>
>>> For example, I have a set of objects that go like this...
>>>
>>> exam request
>>>   - student
>>>     - list of telephone numbers
>>>     - list of address
>>>     - list of emails
>>>   - invigilator
>>>     - list of telephone numbers
>>>     - list of address
>>>     - list of emails
>>>
>>> Rather than creating one monolithic query, I'd like to have one query
>>> for each of the following, but still have them put into the Java class
>>> tree listed above.  I understand that this will take longer to query,
>>> as it would need to hit the database multiple times, but it's far
>>> easier to debug, and maintain.
>>>
>>> - person
>>> - telephone numbers for person
>>> - addresses for person
>>> - emails for person
>>>
>>> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
In reply to this post by Eduardo Macarron
On Sat, Feb 4, 2012 at 10:50 PM, Eduardo <[hidden email]> wrote:
> All the mapping is done in resultmaps, event nested selects are on
> them.
>
> Try it and let us know how it went.

I cannot find anything about "event nested selects" on the page at
http://www.mybatis.org/core/sqlmap-xml.html

I used auto-complete on the resultMap element, to see if it would show
some sort of event nested selects, but nothing useful came up.

Anyhow, I don't think discriminator is what I need.  I don't need to
do different thing based on the results.  I need to load different
objects based on different columns.  For example, a student ID column
would come out in the first select.  I could use that to do another
query to go grab all the student data.  Another column would be an
exam invigilator's ID.  But I don't need to compare their values to
anything, I just need to load data using that value.

>
> On 5 feb, 06:06, "Trenton D. Adams" <[hidden email]> wrote:
>> I'll try that on Monday, when I get back to work, but that doesn't
>> look like what I need.  It appears, based on the documentation, that
>> it can simply apply another ResultMap to parts of the result, based on
>> what a certain value is in that result.  It doesn't appear that it can
>> apply an entirely new select though.
>>
>>
>>
>>
>>
>>
>>
>> On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:
>> > Discriminator should let you do it.
>> >http://www.mybatis.org/core/sqlmap-xml.html
>>
>> > On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>> >> Hello,
>>
>> >> I'd like to know if mybatis has functionality that will allow me to
>> >> make additional queries, based on data results from a primary query,
>> >> and do something similar to what associations do.
>>
>> >> For example, I have a set of objects that go like this...
>>
>> >> exam request
>> >>   - student
>> >>     - list of telephone numbers
>> >>     - list of address
>> >>     - list of emails
>> >>   - invigilator
>> >>     - list of telephone numbers
>> >>     - list of address
>> >>     - list of emails
>>
>> >> Rather than creating one monolithic query, I'd like to have one query
>> >> for each of the following, but still have them put into the Java class
>> >> tree listed above.  I understand that this will take longer to query,
>> >> as it would need to hit the database multiple times, but it's far
>> >> easier to debug, and maintain.
>>
>> >> - person
>> >> - telephone numbers for person
>> >> - addresses for person
>> >> - emails for person
>>
>> >> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
Again, never mind, I found nested selects in the PDF manual.  There
was nothing using the word "event".  They are called "nested selects".
:D

I'll try them out, and let you know how it goes.

On Mon, Feb 6, 2012 at 10:32 AM, Trenton D. Adams
<[hidden email]> wrote:

> On Sat, Feb 4, 2012 at 10:50 PM, Eduardo <[hidden email]> wrote:
>> All the mapping is done in resultmaps, event nested selects are on
>> them.
>>
>> Try it and let us know how it went.
>
> I cannot find anything about "event nested selects" on the page at
> http://www.mybatis.org/core/sqlmap-xml.html
>
> I used auto-complete on the resultMap element, to see if it would show
> some sort of event nested selects, but nothing useful came up.
>
> Anyhow, I don't think discriminator is what I need.  I don't need to
> do different thing based on the results.  I need to load different
> objects based on different columns.  For example, a student ID column
> would come out in the first select.  I could use that to do another
> query to go grab all the student data.  Another column would be an
> exam invigilator's ID.  But I don't need to compare their values to
> anything, I just need to load data using that value.
>
>>
>> On 5 feb, 06:06, "Trenton D. Adams" <[hidden email]> wrote:
>>> I'll try that on Monday, when I get back to work, but that doesn't
>>> look like what I need.  It appears, based on the documentation, that
>>> it can simply apply another ResultMap to parts of the result, based on
>>> what a certain value is in that result.  It doesn't appear that it can
>>> apply an entirely new select though.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:
>>> > Discriminator should let you do it.
>>> >http://www.mybatis.org/core/sqlmap-xml.html
>>>
>>> > On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>>> >> Hello,
>>>
>>> >> I'd like to know if mybatis has functionality that will allow me to
>>> >> make additional queries, based on data results from a primary query,
>>> >> and do something similar to what associations do.
>>>
>>> >> For example, I have a set of objects that go like this...
>>>
>>> >> exam request
>>> >>   - student
>>> >>     - list of telephone numbers
>>> >>     - list of address
>>> >>     - list of emails
>>> >>   - invigilator
>>> >>     - list of telephone numbers
>>> >>     - list of address
>>> >>     - list of emails
>>>
>>> >> Rather than creating one monolithic query, I'd like to have one query
>>> >> for each of the following, but still have them put into the Java class
>>> >> tree listed above.  I understand that this will take longer to query,
>>> >> as it would need to hit the database multiple times, but it's far
>>> >> easier to debug, and maintain.
>>>
>>> >> - person
>>> >> - telephone numbers for person
>>> >> - addresses for person
>>> >> - emails for person
>>>
>>> >> Any help would be much appreciated.  Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: additional queries and associations

Trenton D. Adams
Okay, it seems to be working now.  Thanks for the help Eduardo.

On Mon, Feb 6, 2012 at 10:35 AM, Trenton D. Adams
<[hidden email]> wrote:

> Again, never mind, I found nested selects in the PDF manual.  There
> was nothing using the word "event".  They are called "nested selects".
> :D
>
> I'll try them out, and let you know how it goes.
>
> On Mon, Feb 6, 2012 at 10:32 AM, Trenton D. Adams
> <[hidden email]> wrote:
>> On Sat, Feb 4, 2012 at 10:50 PM, Eduardo <[hidden email]> wrote:
>>> All the mapping is done in resultmaps, event nested selects are on
>>> them.
>>>
>>> Try it and let us know how it went.
>>
>> I cannot find anything about "event nested selects" on the page at
>> http://www.mybatis.org/core/sqlmap-xml.html
>>
>> I used auto-complete on the resultMap element, to see if it would show
>> some sort of event nested selects, but nothing useful came up.
>>
>> Anyhow, I don't think discriminator is what I need.  I don't need to
>> do different thing based on the results.  I need to load different
>> objects based on different columns.  For example, a student ID column
>> would come out in the first select.  I could use that to do another
>> query to go grab all the student data.  Another column would be an
>> exam invigilator's ID.  But I don't need to compare their values to
>> anything, I just need to load data using that value.
>>
>>>
>>> On 5 feb, 06:06, "Trenton D. Adams" <[hidden email]> wrote:
>>>> I'll try that on Monday, when I get back to work, but that doesn't
>>>> look like what I need.  It appears, based on the documentation, that
>>>> it can simply apply another ResultMap to parts of the result, based on
>>>> what a certain value is in that result.  It doesn't appear that it can
>>>> apply an entirely new select though.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sat, Feb 4, 2012 at 11:17 AM, Eduardo <[hidden email]> wrote:
>>>> > Discriminator should let you do it.
>>>> >http://www.mybatis.org/core/sqlmap-xml.html
>>>>
>>>> > On 3 feb, 20:02, Trenton <[hidden email]> wrote:
>>>> >> Hello,
>>>>
>>>> >> I'd like to know if mybatis has functionality that will allow me to
>>>> >> make additional queries, based on data results from a primary query,
>>>> >> and do something similar to what associations do.
>>>>
>>>> >> For example, I have a set of objects that go like this...
>>>>
>>>> >> exam request
>>>> >>   - student
>>>> >>     - list of telephone numbers
>>>> >>     - list of address
>>>> >>     - list of emails
>>>> >>   - invigilator
>>>> >>     - list of telephone numbers
>>>> >>     - list of address
>>>> >>     - list of emails
>>>>
>>>> >> Rather than creating one monolithic query, I'd like to have one query
>>>> >> for each of the following, but still have them put into the Java class
>>>> >> tree listed above.  I understand that this will take longer to query,
>>>> >> as it would need to hit the database multiple times, but it's far
>>>> >> easier to debug, and maintain.
>>>>
>>>> >> - person
>>>> >> - telephone numbers for person
>>>> >> - addresses for person
>>>> >> - emails for person
>>>>
>>>> >> Any help would be much appreciated.  Thanks.
Loading...