Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id CCBD01337BC3 for ; Mon, 28 Mar 2011 11:38:23 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 09184-05 for ; Mon, 28 Mar 2011 14:38:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from claranet-outbound-smtp04.uk.clara.net (claranet-outbound-smtp04.uk.clara.net [195.8.89.37]) by mail.postgresql.org (Postfix) with ESMTP id 1CB9E1337BA8 for ; Mon, 28 Mar 2011 11:38:13 -0300 (ADT) Received: from [217.158.205.40] (port=51325 helo=BSP1.visitlondon.com) by relay04.mail.eu.clara.net (relay.clara.net [213.253.3.44]:1025) with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) id 1Q4Da8-0007Uk-DM (return-path ); Mon, 28 Mar 2011 14:38:12 +0000 thread-index: AcvtVcI0ZOc91SCoS22z1WcheqaksA== Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18263 Message-ID: <4D909D51.3020104@visitlondon.com> Date: Mon, 28 Mar 2011 15:38:09 +0100 From: Chris Wareham Organization: Visit London User-Agent: Mozilla/5.0 (X11; U; NetBSD i386; en-US; rv:1.9.2.14) Gecko/20110308 Lightning/1.0b3pre Thunderbird/3.1.8 MIME-Version: 1.0 To: "Lew" CC: Subject: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 References: <1300923357612-4259788.post@n5.nabble.com> <1301299364557-4267176.post@n5.nabble.com> <4D905F65.4030207@visitlondon.com> In-Reply-To: Content-Type: text/plain; format=flowed; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: none X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201103/96 X-Sequence-Number: 21651 On 03/28/11 14:27, Lew wrote: > Chris Wareham wrote: >> Dave Cramer wrote: >>> Ok, looking at the hibernate source this is what is in the = PostgreSQLDialect >>> >>> public String getIdentitySelectString(String table, String column, = int type) { >>> return new StringBuffer().append("select currval('") >>> .append(table) >>> .append('_') >>> .append(column) >>> .append("_seq')") >>> .toString(); >>> } >>> } > >> Just as an aside, should that not be using a StringBuilder rather = than >> a StringBuffer? Or does Hibernate still explicitly support Java 1.4? > > My Red-Flag-O-Meter triggered on that, too. What Hibernate ought to = do is: > > return "select currval('" + table + '_' + column + "_seq')"; > > for Pete's sake. > > I'm off to check if EclipseLink or OpenJPA is better written. > I was flagging this up due to StringBuffer's locking, despite it being used in a local scope - in other words, it doesn't need to be thread safe, so the locking overhead can be avoided by using a StringBuilder instead. As I suggested, perhaps Hibernate still supports Java 1.4, or wasn't rototilled for this kind of thing when 1.4 support was dropped. If it's still a common idiom across the Hibernate codebase then it would be nice to see it changed. You're right that in this case concatenation will achieve the same thing as using an explicit StringBuilder, at least in Java 1.6[1]. Chris [1] http://kaioa.com/node/59 -- =20 Chris Wareham Senior Software Engineer Visit London Ltd 6th floor, 2 More London Riverside London SE1 2RR =20 Tel: +44 (0)20 7234 5848 Fax: +44 (0)20 7234 5753 =20 http://www.visitlondon.com/ =20 =20 'Visit London Limited' is registered in England under No.761149; Registered Office: Visit London, 2 More London Riverside, London SE1 = 2RR. =20 Visit London is the official visitor organisation for London. Visit = London is partly funded by Partnership, the Mayor's London Development = Agency and London Councils. The information contained in this e-mail is confidential and intended = for the named recipient(s) only. If you have received it in error, = please notify the sender immediately and then delete the message. If you = are not the intended recipient, you must not use, disclose, copy or = distribute this email. The views expressed in this e-mail are those of = the individual and not of Visit London. We reserve the right to read and = monitor any email or attachment entering or leaving our systems without = prior notice. =20 Please don't print this e-mail unless you really need to.