db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fox <Thomas....@seitenbau.net>
Subject two-arg criteria constructor and SqlEnum
Date Sat, 22 Sep 2012 15:15:55 GMT


It seems that with the new Criteria API, people are tempted to do

criteria.and(SomePeer.SOME_COLUMN, Criteria.IS_NOT_NULL); // Criteria.and
(Object, Object)

which is currently equivalent to

criteria.and(SomePeer.SOME_COLUMN, Criteria.IS_NOT_NULL, Criteria.EQUAL);

which of course is senseless.

Currently, we do not check the two args.
In my opinion, it makes sense to forbid using a SqlEnum as first argument
by throwing an IllegalArgumentException.

But what should we do with the example above ? Should we
a) also throw an IllegalArgumentException if the second argument is a
SqlEnum
or
b) if the second argument is a SQLEnum, check that it is a one-arg operator
and map it to criteria.and(arg1, null, operator) (which is ptrobably what
the user meant to do) (If the operator is a two-arg operator, throw an
IllegalArgumentException)

I have a slight tendency towards b). Same for criteria.or,
criteria.where, ....
Any other opinions ?

    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