From: | Віталій Тимчишин <tivv00(at)gmail(dot)com> |
---|---|
To: | Dave Cramer <pg(at)fastcrypt(dot)com> |
Cc: | Lew <noone(at)lewscanon(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 |
Date: | 2011-03-28 14:31:19 |
Message-ID: | AANLkTinbK92ZRqUqgfnB41NCgzX59xUa+Byt5EkFTa9n@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
2011/3/28 Dave Cramer <pg(at)fastcrypt(dot)com>
> On Mon, Mar 28, 2011 at 9:27 AM, Lew <noone(at)lewscanon(dot)com> 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.
>
>
> Really ??? the last time I checked the above will generate approx 5
> objects StringBuffer.append is the recommended use for java 1.4,
> StringBuilder is only marginally faster as it not synchronized.
>
> + or concat is much slower as it creates a new object each time and
> copies the old into the new.
>
Have just checked with decompiler - It is exactly same if 1 expression with
multiple pluses is used, one StringBuilder (StringBuffer for J1.4) is
created, then multiple .append calls, then toString. Explicit StringBuilder
should be used only in multiple expressions (e.g. in famount str += value in
for circle). For single expression "+" gives same result, but is more
readable and will choose StringBuilder/StringBuffer automatically depending
on java version.
--
Best regards,
Vitalii Tymchyshyn
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Wareham | 2011-03-28 14:38:09 | Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 |
Previous Message | Dave Cramer | 2011-03-28 14:08:04 | Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4 |