Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Дата
Msg-id AANLkTikKLf4mQe8GKD9JeT8ksJB7-RRVVg+-2Jui-xQq@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4  (Віталій Тимчишин <tivv00@gmail.com>)
Список pgsql-jdbc
2011/3/28 Віталій Тимчишин <tivv00@gmail.com>:
>
>
> 2011/3/28 Dave Cramer <pg@fastcrypt.com>
>>
>> On Mon, Mar 28, 2011 at 9:27 AM, Lew <noone@lewscanon.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.
>

Apparently my memory is failing because I used to know that modern
compilers used StringBuffer, apparently they are even better and use
StringBuilder when given the chance. Either way it's moot since it is
hibernate's code.


Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Chris Wareham
Дата:
Сообщение: Re: Problems with Hibernate Discriminators and 9.0-801.jdbc4
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: idea to have driver return immediately after a query