Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z8yJI-0007Sx-Ip for pgsql-jdbc@arkaria.postgresql.org; Sat, 27 Jun 2015 22:10:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Z8yJH-0003d2-NG for pgsql-jdbc@arkaria.postgresql.org; Sat, 27 Jun 2015 22:10:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8yJG-0003cg-CR for pgsql-jdbc@postgresql.org; Sat, 27 Jun 2015 22:10:50 +0000 Received: from smtprelay01.ispgateway.de ([80.67.31.39]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8yJ9-0007KS-2U for pgsql-jdbc@postgresql.org; Sat, 27 Jun 2015 22:10:49 +0000 Received: from [88.66.31.4] (helo=Zauselmaus) by smtprelay01.ispgateway.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1Z8yJ7-0002DU-N5 for pgsql-jdbc@postgresql.org; Sun, 28 Jun 2015 00:10:41 +0200 From: "Markus KARG" To: "'List'" References: <558ED5A6.4070500@8Kdata.com> <002701d0b104$114cdd60$33e69820$@eu> <558F15C7.5060309@8Kdata.com> In-Reply-To: <558F15C7.5060309@8Kdata.com> Subject: Re: SQLJSON Date: Sun, 28 Jun 2015 00:10:40 +0200 Organization: Markus KARG, Staatl. gepr. Inf. Message-ID: <001a01d0b126$1ab09c80$5011d580$@eu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdCxIIOte4H92XHcSMOuCJjItIun/gABMfJw Content-Language: de X-AVK-Virus-Check: AVA 25.2250;789163EA X-AVK-Spam-Check: 1; str=0001.0A0C0203.558F1F61.00C6,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0; F1206 X-Df-Sender: bWFya3VzQGhlYWRjcmFzaGluZy5ldQ== X-Pg-Spam-Score: -1.1 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org (1) I have no problem with providing a JSON Object. I just want to point out that it cannot be the final solution from the point of a USER as it implies horrible performance drawbacks. (2) A default parser bundled with pgjdbc simply makes no sense as (a) in a Java EE environment a JSONP API provider IS found on the classpath already, and (b) it is not unlikely that the same will be the case for Java SE 9 due to the implied importance of JSON these days, and (c) an application programmer dealing with JSON has to have a JSON parser anyways, even if he does not use JDBC at all. -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of =C1lvaro Hern=E1ndez Tortosa Sent: Samstag, 27. Juni 2015 23:30 To: pgsql-jdbc@postgresql.org Subject: Re: [JDBC] SQLJSON On 27/06/15 20:07, Markus KARG wrote: > =C1lvaro, > > I also think we should look at the topic with the eyes of the user, but I > have to disagree in two point exactly due to that attitude: Hi Markus. Good that we agree on that :) > > (1) JSON is definitively not just another datatype. Just like XML, it > provides the ability to return a complete object graph as the content of one > column of one row. Hence, it contains the same amount of data that in > pre-XML and pre-JSON times, the ResultSet did handle alone. Or in other > words, from the complexity of the information and from the aspect of end > user performance, it "feels" like a ResulSet that contains ResultSets that > contains ResultSets... Handling it just like any other datatype is what > pgjdbc does currently, and it provides very poor performance due to that, as > it simply ships the complete graph - independent of the fact whether the end > user will process is completely or just pick a single node of it. Asking to > handle JSON as just any other data type is like asking to give up ResultSet > in favor of returning an ArrayList>! So looking with the eyes > of an end user, the answer must be, to NOT handle JSON like any other > datatype, and NOT return a JsonObject, but instead provide a streaming API, > just like SQLXML does. This allows to only transfer and process that few > nodes the the end user actually likes to have, just like an end user > typically will never process a complete ResultSet but process it iteratively > and most typically filtered. When I said "as just another datatype", I mean "as simple as". So=20 from a user perspective I would expect to have a get...JSON() method=20 with return value an object similar to (or IMHO exactly) JsonObject. In=20 other words, something directly usable. As Dave Cramer correctly points out in response earlier in this=20 thread, there is no way in current PostgreSQL support to send a partial=20 chunk of the JSON, so --unfortunately-- streaming API is not possible.=20 Not being it possible, why not provide methods to return JsonObject, the=20 Java EE standard and defined by a JSR? > > (2) The user MUST be always asked to provide a JSON parser, as it is HIM who > wants to use JSON, and so it is HIS choice to select one among those > fulfilling the JSONP API standard. Hence it makes no sense that pgjdbc picks > and / or provides one. Most typically this will end up in the same design > choice than most XML applications ended up with: Relying on Java SE / EE > providing a default product, like it is the case with JAXB (Xerces). The > only thing pgjdbc can really do NOW is to support the JSON SPI *if* there is > a processor on the classpath, and once the postgresql server produces an > improved streaming procotol for JSON / XML we can couple the client's JSON > event handler with the server's protocol events. Why not instead provide a default parser and let the user choose=20 another one if so she wants? It makes life easier for 90% of users who=20 don't care or even know about which parser to choose. Providing a=20 sensible default (or just a working default) is better than providing none. Regards, =C1lvaro --=20 =C1lvaro Hern=E1ndez Tortosa ----------- 8Kdata > > Regards > Markus > > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of =C1lvaro Hern=E1ndez > Tortosa > Sent: Samstag, 27. Juni 2015 18:56 > To: pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] SQLJSON > > > On 26/06/15 19:29, Steven Schlansker wrote: >> On Jun 26, 2015, at 10:23 AM, Dave Cramer wrote: >> >>> On 26 June 2015 at 13:01, Steven Schlansker > wrote: >>> On Jun 26, 2015, at 7:57 AM, Dave Cramer wrote: >>> >>>> I'm looking for comments on how to implement a SQLJSON type in JDBC. >>>> >>>> As there is no getSQLJSON in the resultset interface this could only be > used in getObject. >>>> Notionally it would model itself after SQLXML. >>>> https://docs.oracle.com/javase/7/docs/api/index.html?java/sql/SQLXML >>>> .html >>> I used JSON extensively in one of my projects, but have never used > SQLXML. I'm having trouble understanding why the SQLXML interface adds any > value to passing rs.getBinaryStream to your favorite JSON parser. > Especially since you would have to use getObject, I am not seeing how: >>> rs.getObject("field", SQLJSON.class).mapToType(MyType.class) >>> >>> is simpler than: >>> jacksonObjectMapper.readValue(rs.getBinaryStream("field"), >>> MyType.class) >>> >>> which already works today as far as I understand. Doubly so since nobody > will agree on which JSON parsing library to use. >>> I'm sure I'm missing something? >>> >>> >>> I don't think you are; as you rightly pointed out now we would have >>> to add a json parser to the driver, which I'm reluctant to do >>> >> If this feature is developed, I think the JSON parser should be pluggable > and optional if possible. Then users that do not want it do not need to > drag in a large dependency. >> That said, without a more convincing use case or a compelling API that we > could easily add, I don't see this interface being "worth its weight" as an > addition. >> >> > Hi List. > > I always try to think more from the user perspective than from the > developer one. This is also going to be the case. > > Having JSON support in the PostgreSQL JDBC driver is a *must*. > jsonb was 9.4's next-big-thing-since-sliced-bread jet there's no support in > one of the most used PostgreSQL drivers. No blame here (at all), just trying > to support my point here. > > I don't see the advantage of using SQLJSON, although I wouldn't argue > against. What I clearly believe is that at the end of the day you should be > able to easily return a javax.json.JsonObject from a ResultSet. Being a > JavaEE standard and a JSR, I believe it's the best (and obvious) choice. > > Regarding pluggability, JSR353's SPI mechanism is good, but asking the > user to provide a further dependency "just for reading JSON" seems again to > me not good from the user perspective. I'd ideally expect json to be > supported as-is, as with any other datatype. Having the SPI we could choose > whatever implementation we want. Is that enlarging the driver's size? So > what? Users want easy-of-use, not driver size. And there are many mechanisms > to reduce size for unused classes. > > If any, my 2 cents are: let's add JSON, let's take JSR353 as an API for > it and let's make it as easy as possible for final users to use it. > > Regards, > > =C1lvaro > > > > -- > =C1lvaro Hern=E1ndez Tortosa > > > ----------- > 8Kdata > > > --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc --=20 Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc