Return-Path: X-Original-To: apmail-cayenne-user-archive@www.apache.org Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 46B3118BF6 for ; Tue, 13 Oct 2015 15:17:15 +0000 (UTC) Received: (qmail 49120 invoked by uid 500); 13 Oct 2015 15:16:59 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 49092 invoked by uid 500); 13 Oct 2015 15:16:59 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 49080 invoked by uid 99); 13 Oct 2015 15:16:59 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2015 15:16:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 53C26180E3C for ; Tue, 13 Oct 2015 15:16:58 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id gwc0jiIB_-NY for ; Tue, 13 Oct 2015 15:16:49 +0000 (UTC) Received: from mail-03.1984.is (mail-03.1984.is [93.95.224.70]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 599CA42B97 for ; Tue, 13 Oct 2015 15:16:49 +0000 (UTC) Received: from localhost by mail-03.1984.is with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.84) (envelope-from ) id 1Zm1Jn-00024R-U7 for user@cayenne.apache.org; Tue, 13 Oct 2015 15:16:47 +0000 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) Subject: Re: likeIgnoreCase queries and EJBQL From: Hugi Thordarson In-Reply-To: Date: Tue, 13 Oct 2015 15:16:42 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <8945123D-5A85-4AF9-8B4D-D01F480F037D@karlmenn.is> References: <7F50BDE2-E500-4CA6-B93B-8CA24810066F@karlmenn.is> <90705ED1-A8AE-4694-8845-E279747E7CA8@objectstyle.org> To: user@cayenne.apache.org X-Mailer: Apple Mail (2.3094) I=E2=80=99m not sure how useful my work would be since I=E2=80=99m = writing against a 15 year old Informix version, incompatible with modern = JDBC-drivers (for example, modern Informix JDBC drivers support {fn = ucase} just fine). We=E2=80=99re planning to switch this customer to = Postgres as soon as they have the resources. But I=E2=80=99ll of course be happy to contribute any code I create if = anyone happens to need to communicate with Informix 9.30 in the future = :) Cheers, - hugi > On 13. okt. 2015, at 14:55, Andrus Adamchik = wrote: >=20 > Awesome. Congrats :) >=20 > Perhaps with your help we can create a fully working Informix adapter = in Cayenne? >=20 > Andrus >=20 >> On Oct 13, 2015, at 10:49 AM, Hugi Thordarson = wrote: >>=20 >> Eeek=E2=80=94I actually did it, and it works like a charm! Found out = my factory needed to override getConditionTranslator(), not = getSelectTranslator(). >>=20 >> https://gist.github.com/hugith/f04fd044b59c4ce60aa9 >>=20 >> For the first time, I feel like a total Cayenne Boss=E2=84=A2 :) >>=20 >> - hugi >>=20 >>=20 >>=20 >>> On 13. okt. 2015, at 14:45, Hugi Thordarson = wrote: >>>=20 >>>> {fn ucase} is JDBC escape syntax, so presumably the driver should = convert that to the proper syntax. If a given driver is not capable of = doing that, that has to be addressed in DbAdapter for that DB. = DbAdapter.getEjbqlTranslatorFactory() is how you customize EJBQL = translation. So Mike is right about that. >>>=20 >>> Thanks=E2=80=A6 I=E2=80=99ve created my adaptor and ensured that = it=E2=80=99s being used along with my new = InformixEJBQLSelectTranslator=E2=80=94but I=E2=80=99m not getting any = invocations of visitUpper and the code generated still contains {fn = ucase(=E2=80=A6)}. Shouldn=E2=80=99t visitUpper() be where I hook into = the generation of the upper statement for the DB? >>>=20 >>> https://gist.github.com/hugith/bb68f1944f7a7d754363 >>>=20 >>>> BTW, which DB are we talking about? >>>=20 >>> Ah, well=E2=80=A6 It=E2=80=99s informix=E2=80=94 and an old version = at that. So I would probably always have had to create my own DbAdaptor = anyway. >>>=20 >>> Cheers, >>> - hugi >>>=20 >>>=20 >>>>=20 >>>> Andrus >>>>=20 >>>>=20 >>>>> On Oct 13, 2015, at 5:31 AM, Hugi Thordarson = wrote: >>>>>=20 >>>>> Thanks Mike! >>>>>=20 >>>>> I=E2=80=99m not sure it this is a database plugin problem though. = Doing regular case insensitive queries works fine, it=E2=80=99s only = queries created from EJBQL that fail. Also, the only place in the = Cayenne sources I can find a mention of =E2=80=9Cucase" is in = EJBQLTranslator=E2=80=99s visitUpper(). Perhaps changing that method to = do upper( rather than {fn ucase. might solve the problem? I=E2=80=99m = going to try that out :). >>>>>=20 >>>>> = https://github.com/apache/cayenne/blob/master/cayenne-server/src/main/java= /org/apache/cayenne/access/translator/ejbql/EJBQLConditionTranslator.java#= L1058 >>>>>=20 >>>>> Cheers, >>>>> - hugi >>>>>=20 >>>>>=20 >>>>>=20 >>>>>=20 >>>>>> Sounds like the DbAdaptor for that database needs to be = special-cased. >>>>>> Lots of examples of how this is done in cayenne/dba//*, >>>>>> especially for oracle >>>>>>=20 >>>>>> And it's pretty simple to set your app up to use a custom version = of >>>>>> the dbAdaptor if you don't want to build your own custom version = of >>>>>> cayenne while you wait until it's included in a release. >>>>>>=20 >>>>>> On Mon, Oct 12, 2015 at 12:46 PM, Hugi Thordarson = wrote: >>>>>>> Hi all. >>>>>>>=20 >>>>>>> I=E2=80=99m communicating with a database that doesn=E2=80=99t = have the UCASE function, only UPPER. >>>>>>>=20 >>>>>>> When I use case insensitive expressions (for example, = User.NAME.likeIgnoreCase(=E2=80=9CBob=E2=80=9D)) in a regular = SelectQuery, Cayenne generates SQL using the =E2=80=9CUPPER=E2=80=9D = function (for expressions generated using likeIgnoreCase). This works = fine. >>>>>>>=20 >>>>>>> But if I generate EJBQL from the expression and then use the = resulting string to perform an EJBQLQuery, Cayenne will attempt to use = UCASE function in the resulting SQL and things go awry. >>>>>>>=20 >>>>>>> Can I tell the EJBQL SQL translator to use =E2=80=9Cupper=E2=80=9D= rather than =E2=80=9Cucase=E2=80=9D when performing these queries? >>>>>>>=20 >>>>>>> Cheers, >>>>>>> - hugi >>>>>=20 >>>>>=20 >>>>=20 >>>=20 >>=20 >>=20 >=20