ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: N+1 with column renaming
Date Thu, 03 Nov 2005 03:23:39 GMT
+1 

That's exactly what I do too.

--- Larry Meadors <lmeadors@apache.org> wrote:

> I generally name my key fields uniquely, but leave the others what
> they are, for example:
> 
> create table Fruit (
>   fruitId int,
>   name varchar(30)
> )
> 
> Then if I join to another table with a "name" field, I alias them to
> include the table name (so, in this case i would use "fruitName").
> 
> That said..it really does not matter for the N+1 selects solution,
> becuase it relies on the property names, not the field names. :-)
> 
> Larry
> 
> 
> On 11/1/05, Paul Benedict <paul4christ79@yahoo.com> wrote:
> > Maybe someone has encountered this problem and would
> > like to lend a hand.
> >
> > Many of the tables that I have have column names that
> > are not unique across tables. At the moment, I have
> > taken the solution to rename each column in my query
> > and each resultMap knows what to look for:
> >
> >   <resultMap id="fruitMap" class="Fruit">
> >     <result property="id" column="f_id"/>
> >     <result property="name" column="f_name"/>
> >   </resultMap>
> >
> > So I have the convention that any columns from the
> > Fruit table will be returned as f_, anything from the
> > Vegetables column be v_, etc. This then allows me to
> > query multiple tables when solving the N+1 problem and
> > not get things confused.
> >
> > But is there a better way?
> >
> 


Mime
View raw message