[OJB-developers] Re: SqlStatement
Brought to you by:
thma
From: Oleg N. <on...@uk...> - 2002-05-16 22:47:50
|
Hi Jakob, On Thursday 16 May 2002 08:52, Jakob Braeuchi wrote: > i have a problem with ms-access (to support it is an ojb feature) and joins > using the current version of SqlStatement. > > SELECT DISTINCT A0.id,A0.idPerson,A0.nummer,A0.saldo FROM tabKonto A0 INNER > JOIN tabPerson A1 ON A0.idPerson=A1.id INNER JOIN tabTelefon A2 ON > A1.id=A2.idPerson WHERE (A0.saldo>?) AND A2.tel_nr LIKE ? > > this is perfect for mysql but ms-access needs ( ) around nested joins : > > SELECT DISTINCT A0.id,A0.idPerson,A0.nummer,A0.saldo FROM (tabKonto A0 > INNER JOIN tabPerson A1 ON A0.idPerson=A1.id) INNER JOIN tabTelefon A2 ON > A1.id=A2.idPerson WHERE (A0.saldo>?) AND A2.tel_nr LIKE ? > > i've attached a fixed SqlStatement that works with mysql and ms-access, but > i've NOT tested it with hsql and others. > could you please have a look at it ? The way you insert parenthesis doesn't look natural for me, it doesn't express the tree structure of joins :) I'd prefer to return to the original way and to use join syntax without parenthesis for HSQL and MySQL only. I've committed my verion. Please, let me know what you think. > when tryinig to understand your code, i saw that you make heavy use of > instance variables. > this is undoubtably perfect for performance, but i think it will complicate > future refactorings. > i prefer parameter passing (ie: for stmt in appendTableWithJoins() ). I agree, actually I usually prefer to use parameter passing and I tell to others the same things that you told to me :) And BTW I am not sure that instance variables are better for performance :) I just tried to make the source code as simple as possible. I will remove several instance variables. Thanks, Oleg |