ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: A couple newbie questions
Date Wed, 05 Dec 2007 22:26:17 GMT
1. Define "the join doesn't work".  If you mean that the database chokes on
f.bork and b.bork then you have a seriously messed up database and you
should throw it out immediatly.

If you mean that iBATIS can't distingush between the different columns, then
that is correct behavior.  You need to rename at least one of the columns
(and the corresponding propery in your result object):

select f.bork, b.bork as ANOTHER_BORK
from ...

2.  Batches are only for inserts, updates, deletes.  They do not apply for
selects.

Jeff Butler

On Dec 5, 2007 3:57 PM, Brian Parkinson <parki@avaning.com> wrote:

>  Hello!
>
>
>
> I'm new to iBATIS, but loving it so far – decided to go with iBATIS as
> opposed to Hibernate for simplicity, and to have arguably more control over
> the SQL. I have a couple questions (apologies if these are covered in hthe
> FAQ, but I couldn't find):
>
>
>
> 1. I have a pretty complex join, and so am using the groupBy pattern
> (whereby the ResultMap for the top level object references child resultMaps,
> with groupBy, and using LEFT OUTER joins) – basically straight from the
> docs. It looks something like:
>
>
>
> <select id="Foo.select_by_id" parameterClass="string"
> resultMap="FooResultMap">
>
>   SELECT
>
>     f.name, f.address, f.phone,
>
>     t.colour, t.shape, t.size
>
>   FROM Foo f
>
>   LEFT OUTER JOIN Bar b on f.ID <http://f.id/> = b.ID <http://b.id/>
>
>   WHERE f.name = #value#;
>
> </select>
>
>
>
> This is cool – my real code has many more JOINs, but you get the idea.
>
>
>
> The problem is, if both the Foo table **and** the Bar table contain a
> column with the **same** name, then the JOIN doesn't work, even when
> distinguished as f.bork and b.bork.
>
>
>
> Is there a workaround for this?
>
>
>
> 2. Due to the problem above, I'm running a number of select queries, and
> building up the result (ie. in the example above, I'd make one query for the
> Bar object(s) and then the Foo object and call foo.setBar(bar) to build
> things up.
>
>
>
> The question – if I put this in a batch statement, can I expect a good
> performance boost?
>
>
>
> Any help or tips on how best to structure this stuff is appreciated – I"m
> comfortable with Java, but not much of a SQL expert (at all).
>
>
>
> Any help is greatly appreciated.
>
>
>
> Cheers,
>
>
>
> parki...
>
>
>
> ps. iBATIS is great so far. :)
>
>
>

Mime
View raw message