db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <Fisc...@seitenbau.net>
Subject Re: submitted patch which allows left joins, right joins and explicit inner joins
Date Tue, 10 Aug 2004 09:05:33 GMT


T E Schmitz <mailreg@numerixtechnology.de> schrieb am 06.08.2004 17:53:35:

> Hello,
>>> Note that I did NOT change the code in generator which generates code
>>> selets with joins, e.g. BookPeer.doSelectJoinAuthor(). In my opinion,
>>> would be nice to use a left join there to get also the books without an
>>> author, but I did not want to make too many changes at one time.
>> For backwards compatibility we would need to leave the existing methods
>> as is.  There are I guess two ways forward, either we generate a second
>> set of methods that do left joins or we add an option to the generator
>> to determine if the existing or a left join should be used (I think the
>> latter might be the best option).
> If I could make a suggestion:
> I think the best thing would be to generate something like :
> /** Old method */
> protected static List doSelectJoin_XXX(
> Criteria   criteria,
> Connection connection) throws TorqueException
> {
> return (doSelectJoin_BrandViaBrand1SkippedID(criteria,connection,null));
> }
> /** New method */
> protected static List doSelectJoin_XXX (
> Criteria   criteria,
> Connection connection,
> SqlEnum    joinType) throws TorqueException

I aggree with you that your suggestion is more "backwards compatible" than
the generator option. However, in my opinion, the "standard" join for 99%
of the cases will be a left join, so I would also prefer the generator
option. If one really wants to have an inner join, one could emulate it via
a Criteria object which restricts the FK column to "NOT NULL".

> Note that this requires SqlEnum to be public! Or is there any reason why
> you would not want SqlEnum to be public?

Most of the SqlEnum constants are made available as public constants in the
Criteria object (e.g. Criteria.LEFT_JOIN is a SqlEnum Object), so I do not
see the reason why you had to make SqlEnum public (I diod not have to make
this change). I guess the reason for not making SqlEnum public is the
following: People expect these constants in the Criteria object, so this is
the "default" access point to the constants. As one usually wants only one
access point to avoid confusion, the SqlEnum is not public. In my opinion,
this is a correct decision.


To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message