Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id DFBBDA684DE for ; Mon, 21 May 2012 13:57:25 -0300 (ADT) Received: from auth-smtp.nebula.fi ([217.30.180.105]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SWVv8-0002lL-84 for pgsql-jdbc@postgresql.org; Mon, 21 May 2012 16:57:25 +0000 Received: from quadvadis.localdomain (gw.nitor.fi [83.145.228.24]) (authenticated bits=0) by auth-smtp.nebula.fi (8.13.8/8.13.4) with ESMTP id q4LGv4tR002366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 21 May 2012 19:57:07 +0300 Message-ID: <4FBA73E1.5090106@nitorcreations.com> Date: Mon, 21 May 2012 19:57:05 +0300 From: Mikko Tiihonen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Craig Ringer CC: pgsql-jdbc@postgresql.org Subject: Re: json type References: <4FAB8796.40904@nitorcreations.com> <4FB9FA49.4070409@ringerc.id.au> In-Reply-To: <4FB9FA49.4070409@ringerc.id.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201205/68 X-Sequence-Number: 22968 On 05/21/2012 11:18 AM, Craig Ringer wrote: > On 05/10/2012 05:17 PM, Mikko Tiihonen wrote: >> Hi, >> >> Here is a patch to enable initial support for hstore in the jdbc driver. >> >> With the patch using ResultSet.getObject() on a hstore column and it returns a HashMap >> Similarly a Statement.setObject(Map will send the data to backend using hstore format. > > That's absolutely brilliant, thankyou! > > Of course, now there's a `json' type that folks will probably use much of the time instead, not least because it should be easier to work with from JDBC. I > doubt it'll be as efficient and fast as hstore for single-level key/value info though. Unfortunately there is no standard json type on java side so adding support for json to postgres jdbc is not straight forward. I've been thinking that we could have a code that allows the postgres jdbc user to set the json class to use (gson, org.json, json-simple, jackson) and add some reflection code into the jdbc driver to return path so that it works nicely. And of course the reverse reflection code for sending json to database. -Mikko