X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 25F52D1B7D4 for ; Fri, 18 Jun 2004 21:58:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 92307-09 for ; Sat, 19 Jun 2004 00:58:49 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 1D6EED1B755 for ; Fri, 18 Jun 2004 21:58:45 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1BbUBy-0005qv-00; Sat, 19 Jun 2004 12:58:46 +1200 Message-ID: <40D39015.8090507@opencloud.com> Date: Sat, 19 Jun 2004 13:00:05 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pg@fastcrypt.com Cc: "pgsql-jdbc@postgresql.org" Subject: Re: proposal for CallableStatements to handle multiple out References: <1087582419.15586.173.camel@localhost.localdomain> <40D37653.8010302@opencloud.com> <1087602030.15607.190.camel@localhost.localdomain> <40D386F7.3040401@opencloud.com> <1087605866.15619.193.camel@localhost.localdomain> In-Reply-To: <1087605866.15619.193.camel@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200406/110 X-Sequence-Number: 10312 Dave Cramer wrote: > I'd like to move all of that stuff into it's own class, as the rest of > my patch ends up with alot of if( instanceof CallableStatement) which > I'd like to avoid by putting it all in a CallableStatement > implementation. If I understand what you're suggesting, you want to do this: AbstractJdbc1Statement -> Jdbc1Statement extends AbstractJdbc1Statement -> AbstractJdbc1CallableStatement extends AbstractJdbc1Statement -> Jdbc1CallableStatement extends AbstractJdbc1CallableStatement -> AbstractJdbc2Statement extends AbstractJdbc1Statement The problem is then that you can't reasonably implement AbstractJdbc2CallableStatement: it needs to extend both AbstractJdbc2Statement (to get the extra JDBC2 Statement methods) and AbstractJdbc1CallableStatement (to get the CallableStatement functionality) simultaneously, and Java doesn't let you do mixins or multiple inheritance.. A strategy-object approach would work, though. I'm not sure if it would be much of a win over the current approach though -- you still need all the CallableStatement methods in AbstractJdbc1Statement, they just turn into hooks that call the strategy object's implementation. Have you looked at my patch? It localizes most of the conditionalization of the CallableStatement case into one place (there is an adjustParameterIndex() method that does the index translation; it's an identity transform if the statement isn't a CallableStatement). I'd also prefer an explicit field on the statement to say "this statement is callable!" rather than relying on instanceof, it always struck me as too fragile to rely on exactly which classes the concrete JdbcN classes implement. -O