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 Hugh Ross <hh...@gmail.com> on 2008/01/30 02:42:22 UTC

deep (and wide) inheritance model

I have the good fortune to work on a large domain model, part of which uses
too much inheritance.  I don't want to use a huge outer join with 15 or 20
tables in it.  I'm wondering if I can use RowHandlers to help.  In
particular, is it possible for a RowHandler to replace the object passed to
the handleRow method?

E.g.,
**
*public void handleRow (Object valueObject)
   throws SQLException {
   Person person = (Person) valueObject;
   valueObject = MyFactory.createSubClassObject( person );*
*}
*
Any other sample solutions to this kind of problem are also most welcome...
*
*

Re: deep (and wide) inheritance model

Posted by Harvey Kim <ca...@fastmail.fm>.
It's not safe.  If you have to return a value from "handleRow",
introduce a private variable.

private Person newPersonFromHandleRow;

public void handleRow(Object valueObject)
{
 Person person = (Person) valueObject;
 newPersonFromHandleRow = MyFactory.createSubClassObject( person );
}

But out of curiosity, why would you use "handleRow" to return a single
object?  RowHandler is intended to handle situations where number of
rows being returned from the query is too large to be held into a list.

On Tue, 29 Jan 2008 20:42:22 -0500, "Hugh Ross" <hh...@gmail.com>
said:
> I have the good fortune to work on a large domain model, part of which
> uses
> too much inheritance.  I don't want to use a huge outer join with 15 or
> 20
> tables in it.  I'm wondering if I can use RowHandlers to help.  In
> particular, is it possible for a RowHandler to replace the object passed
> to
> the handleRow method?
> 
> E.g.,
> **
> *public void handleRow (Object valueObject)
>    throws SQLException {
>    Person person = (Person) valueObject;
>    valueObject = MyFactory.createSubClassObject( person );*
> *}
> *
> Any other sample solutions to this kind of problem are also most
> welcome...
> *
> *

-- 
http://www.fastmail.fm - Does exactly what it says on the tin


Re: deep (and wide) inheritance model

Posted by Hugh Ross <hh...@gmail.com>.
I have associations at various levels of the hierarchy.  Some of which are
"many."  I'm trying to avoid having one huge join for all the possible
sub-classes.  Yes, a bunch of smaller queries would be preferred.  (Assuming
they don't repeat/overlap each other a lot.)


On 1/30/08, Christopher Lamey <cl...@localmatters.com> wrote:
>
> So are you basically looking at one big query with a bunch of joined
> tables
> or a bunch of smaller queries to pull it all together?
>
> If so, which one would fit better for your app?
>
> On 1/29/08 6:42 PM, "Hugh Ross" <hh...@gmail.com> wrote:
>
> > I have the good fortune to work on a large domain model, part of which
> uses
> > too much inheritance.  I don't want to use a huge outer join with 15 or
> 20
> > tables in it.  I'm wondering if I can use RowHandlers to help.  In
> > particular, is it possible for a RowHandler to replace the object passed
> to
> > the handleRow method?
> >
> > E.g.,
> > **
> > *public void handleRow (Object valueObject)
> >    throws SQLException {
> >    Person person = (Person) valueObject;
> >    valueObject = MyFactory.createSubClassObject( person );*
> > *}
> > *
> > Any other sample solutions to this kind of problem are also most
> welcome...
> > *
> > *
>
>

Re: deep (and wide) inheritance model

Posted by Christopher Lamey <cl...@localmatters.com>.
So are you basically looking at one big query with a bunch of joined tables
or a bunch of smaller queries to pull it all together?

If so, which one would fit better for your app?

On 1/29/08 6:42 PM, "Hugh Ross" <hh...@gmail.com> wrote:

> I have the good fortune to work on a large domain model, part of which uses
> too much inheritance.  I don't want to use a huge outer join with 15 or 20
> tables in it.  I'm wondering if I can use RowHandlers to help.  In
> particular, is it possible for a RowHandler to replace the object passed to
> the handleRow method?
> 
> E.g.,
> **
> *public void handleRow (Object valueObject)
>    throws SQLException {
>    Person person = (Person) valueObject;
>    valueObject = MyFactory.createSubClassObject( person );*
> *}
> *
> Any other sample solutions to this kind of problem are also most welcome...
> *
> *