You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Amol Chaudhari <av...@gmail.com> on 2007/10/05 12:21:17 UTC

Help needed for representing complex business relationship

Hello All,
We recently started using iBatis. On one of our complex screens we have
requirement like this:
the screen is divided into 5 sections. A single section at the top and 2
sections placed side by side at center and 2 more sections placed side by
side at the bottom.

The relationship is pretty complex here. The topmost section is kind of a
summary section and others are detail sections. So if i select some row at
the top, the LHS middle and LHS bottommost sections will show the details of
the topmost section's summary values. and the RHS middle and RHS bottommost
will show the details of the record selected at the respective LHS sections.
i. e. the topmost section shows the total of some values from the LHS middle
section and LHS bottommost section.

I am thinking of creating a single Business Object representing the whole
screen. It will have 2 List member variables, which will be lists of the
Business objects representing the middle and bottommost sections. i will
then iterate over both these lists and calculate the total (summary) values
to be shown in the topmost section.

Now, the issue is this Object will become huge and if i have even thousands
of rows to be shown in the summary(topmost) section then it will consume
huge amount of memory. I read something about lazy loading of the objects,
but i am not very sure about its use in my case, as i need to get the lists
to calculate the summary values.

Can anyone suggest me a better way to do this?

One of the possible solutions is to separate these objects instead of making
a composite object. But here i am having another issue. some of the values
for my business object come from one query. using those values i can get few
other values from another query and few more from the third query. Now i
don't know how to set multiple values of my Business object from the other
queries. I can map a single value to another query but mapping more than one
is the thing i am stuck at.

Any help will be greatly appreciated.

Regards,
Amol
-- 
View this message in context: http://www.nabble.com/Help-needed-for-representing-complex-business-relationship-tf4574170.html#a13056406
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help needed for representing complex business relationship

Posted by Amol Chaudhari <av...@gmail.com>.
Larry,
Thanks for the reply. But I am not so sure about it.
Anyway, i am exploring the option of using rowhandler. Lets see if i can use
it effectively.
-- 
View this message in context: http://www.nabble.com/Help-needed-for-representing-complex-business-relationship-tf4574170.html#a13090220
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help needed for representing complex business relationship

Posted by Larry Meadors <lm...@apache.org>.
Sounds like you could use a sub-select.

Larry


On 10/5/07, Amol Chaudhari <av...@gmail.com> wrote:
>
> Larry,
> thanks for the reply.
> The issue is i have in the topmost section, few values which are calculated
> from the child lists. So the lists are needed at the time of calculations
> itself.
>
> Anyway, Can you please help me on the following issue:
> Lets say i have a Business object A having a1, a2, a3, a4,a5,a6 as instance
> variables. I am getting a1 and a2 from my initial query. Now, a3,a4 are the
> calculated fields, whose values i can get from another (single) query. also
> a5 is a calculated field whose value also i can get from one more query. and
> a6 = a3+a4+a5 (some formula like this).
> My question is, how can i map the a3,a4 fileds in the resultMap of my
> initial query so that i can populate both the values from a single query?
>
> Regards,
> Amol
> --
> View this message in context: http://www.nabble.com/Help-needed-for-representing-complex-business-relationship-tf4574170.html#a13058357
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: Help needed for representing complex business relationship

Posted by Amol Chaudhari <av...@gmail.com>.
Larry,
thanks for the reply.
The issue is i have in the topmost section, few values which are calculated
from the child lists. So the lists are needed at the time of calculations
itself.

Anyway, Can you please help me on the following issue:
Lets say i have a Business object A having a1, a2, a3, a4,a5,a6 as instance
variables. I am getting a1 and a2 from my initial query. Now, a3,a4 are the
calculated fields, whose values i can get from another (single) query. also
a5 is a calculated field whose value also i can get from one more query. and
a6 = a3+a4+a5 (some formula like this).
My question is, how can i map the a3,a4 fileds in the resultMap of my
initial query so that i can populate both the values from a single query?

Regards,
Amol
-- 
View this message in context: http://www.nabble.com/Help-needed-for-representing-complex-business-relationship-tf4574170.html#a13058357
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Help needed for representing complex business relationship

Posted by Larry Meadors <lm...@apache.org>.
I'd defer fetching the child objects until needed.

This approach offers two advantages:
 - it is simple on the UI side using swing or AJAX
 - it is simple on the iBATIS side, because you don't have to
configure anything complex

Larry


On 10/5/07, Amol Chaudhari <av...@gmail.com> wrote:
>
> Hello All,
> We recently started using iBatis. On one of our complex screens we have
> requirement like this:
> the screen is divided into 5 sections. A single section at the top and 2
> sections placed side by side at center and 2 more sections placed side by
> side at the bottom.
>
> The relationship is pretty complex here. The topmost section is kind of a
> summary section and others are detail sections. So if i select some row at
> the top, the LHS middle and LHS bottommost sections will show the details of
> the topmost section's summary values. and the RHS middle and RHS bottommost
> will show the details of the record selected at the respective LHS sections.
> i. e. the topmost section shows the total of some values from the LHS middle
> section and LHS bottommost section.
>
> I am thinking of creating a single Business Object representing the whole
> screen. It will have 2 List member variables, which will be lists of the
> Business objects representing the middle and bottommost sections. i will
> then iterate over both these lists and calculate the total (summary) values
> to be shown in the topmost section.
>
> Now, the issue is this Object will become huge and if i have even thousands
> of rows to be shown in the summary(topmost) section then it will consume
> huge amount of memory. I read something about lazy loading of the objects,
> but i am not very sure about its use in my case, as i need to get the lists
> to calculate the summary values.
>
> Can anyone suggest me a better way to do this?
>
> One of the possible solutions is to separate these objects instead of making
> a composite object. But here i am having another issue. some of the values
> for my business object come from one query. using those values i can get few
> other values from another query and few more from the third query. Now i
> don't know how to set multiple values of my Business object from the other
> queries. I can map a single value to another query but mapping more than one
> is the thing i am stuck at.
>
> Any help will be greatly appreciated.
>
> Regards,
> Amol
> --
> View this message in context: http://www.nabble.com/Help-needed-for-representing-complex-business-relationship-tf4574170.html#a13056406
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>