Hi!

here is the deal:

Latest activity around Criteria inspired me to try to reimplement the whole 
idea. I drafted some code which i will check in shortly into 
proposals/fedor/nqm (the code is not going to compile, it's just draft)

The basic idea is to refactor & rename everything to make it more OO, solve 
problems Criteria has hard time with, make code duplication virtual zero and 
make it flexible enough to be able to adopt future needs.

here is how it breaks down:

the select criteria or conditions are all represented by Condition interface 
(it is similar to current Criterion)

the class hierarchy of Conditions looks like this:

Condition
|
|----> Comaprison ----> Equal, NotEqual, More, Less etc...
|
|-----> ComplexCondition ----> And, Or

(Yes, I know "ComplexCondition" sounds very medical, go ahead and suggest a 
better name) 

so when you need to get SQL like this:

WHERE A.B=3 AND A.C>5

you'd create the Condition like this:

new And().add(new Equal("A.B", 3)).add(new More("A.C", 5);

if you need smth more complex (pain with Criteria):

WHERE (A.B = 5 and A.C=7) or (A.B=7 and A.C = 15)

is done like this:

new Or()
    .add(new And()
             .add(new Equal("A.B", 5))
             .add(new Equal("A.C", 7)))
    .add(new And()
             .add(new Equal("A.B", 7))
             .add(new Equal("A.C", 15)));


uff... hope you won't have to do that, but at least it does not require any 
nasty hacks and does not take a lot of extra code....

now, that's just WHERE clause, but for a sql query we need a little more like 
select columns, orderby's etc... For that there is Query object which if 
functionally is Criteria less Conditions.

The inheritance here looks like this:

Statement
|
|-----> Query
|
|-----> Update
|
|-----> Delete

Statement provides common stuff like WHERE and FROM clause.
Query also has methods like addSelectColumn, addOrderByColumn etc...

So I am asking for comments/ideas/money ... sorry, no money.
And I propose this as a replacement to current Criteria and related classes. 
Appropriate methods should be added to Peers & OM which would take Condition 
or Query instead of Criteria. At the point when it's fully functional & 
stable Criteria & corresponding Peer methods would be deprecated and at some 
point removed.

Also couple of smaller points: I think those new classes should go into their 
own package at least to make it clear where the new stuff is and where is the 
old one. What do you, guys, think? Also any ideas for the name of the package 
- the best I could come up with is "nqm", which I do not like...

Fedor.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to