You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Charles Anthony <ch...@hpdsoftware.com> on 2005/04/11 18:30:30 UTC
Feature request - or maybe something similar exists and I don't k
now it
Hi,
I'm trying to help one of my developers with a query - and I have to say, I
don't OJB can cope with it at the moment.
Essentially, we want OJB to generate some SQL to do some arithmetic in the
where clause - e.g.
SELECT .... FROM ... WHERE (COLUMNA + COLUMNB - COLUMNC) = 0
I'd like a clean way of OJB generating the correct column names from a
criteria with an arbitrary string containing the attribute names/path
expressions.
e.g.
Criteria crit = new Criteria();
crit.addEqualTo("id", "1");
crit.addGreaterThan("cutOffDate", aDate);
crit.addSql("reconcilliation.amount - reconcilliation.balance = 0")
QueryByCriteria q = new QueryByCriteria(Payment.class, crit);
broker.getCollectionByQuery(q);
=>
SELECT ... FROM PAYMENT A1
INNER JOIN RECONCILLIATION A2 on PAYMENT.RECONCILLIATIONID =
RECONCILLIATION.ID
WHERE
A1.ID = "1" AND
A2.AMOUNT + A2.BALANCE = 0
I'd be happy to surround the attribute references with some kind of quote
e.g.
crit.addSql("$attributeRef{reconcilliation.amount} -
$attributeRef{reconcilliation.balance = 0}") - and I'd be happy to write
some code to extract the references, from the expression and to replace the
references with the field names - but I'm lost as to how, when and where to
actualy convert from attributeRef => qualified column name.
For now, I've actually managed to convert the query to not have a join so I
can work out the column names when I build the criteria (by interrogating
the metadata).
Any suggestions ?
Cheers,
Charles.
___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org