db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fox <Thomas....@seitenbau.net>
Subject Re: Criterions which do not reference a column
Date Thu, 12 Apr 2012 03:02:59 GMT
Thomas Vandahl wrote:
> On 06.04.12 12:00, Thomas Vandahl wrote:
> > Not necessarily. Generifying Criterion could help to clean up the
> > interface quite a bit. I need to look into the code to come up with a
> > good example. Stay tuned... :-)
>
> My proposal for the generified Criterion class is attached. Probably it
> would be useful to have some better restrictions to the generic types (I
> just derived L from Column to see the effects on the code in SqlBuilder)
> and/or a common generified container for the left and right sides of the
> criterion. AFAICS, the influence on other code is not big.
>
> This would need some more thoughts, but from hat I see, I could be worth
> a try.

I am confused.

a) I do not see how the restriction of <L extends column> solves the
original problem, which was to be able to generate SQL such as
select * from TABLE_1 where 0=(select count(*) from TABLE2 where
TABLE2.COLUMN1 = TABLE1.COLUMN1 AND TABLE2.COLUMN2=?);

For this, IMHO the restriction <L extends column> needs to be dropped
(because I will have to construct a Criterion like new Criterion(0,
subqueryCriteria)), and we are left with Criterion<L, R>.

I am also of the opinion that the benefits of using a container on
left/right side (better type checking) are more than outweighed by the more
comlpicated use it causes (having to write new Criterion(new Container(0),
new Container(subqueryCriteria)) in the above case). Because of this, using
a container is not an option IMHO.

b) if a) is correct, I do not see how generifying Criteria adds compile
time safety for the common use case. In nearly all situations, Criterion
Objects will be constructed solely for being added to a Criteria. They will
usually not linger around and will not be queried for their contents (this
is the use case where compile time safety can be gained cause the getter's
return type is not just Object)

c) if b) is correct, then it adds nuisance to write new Criterion<?, ?>()
instead of new Criterion() (more typing.)

So, though I do not doubt that the Criterion object can be generified, I
still do not see the benefits of doing it.

    Thomas


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


Mime
View raw message