Re: getGeneratedKeys() problem

Поиск
Список
Период
Сортировка
От Samuel Gendler
Тема Re: getGeneratedKeys() problem
Дата
Msg-id AANLkTinffcDkExQ-CX393T6cxZXA3NcQhrrLm7MHThXE@mail.gmail.com
обсуждение исходный текст
Ответ на Re: getGeneratedKeys() problem  (Adam Todorski <atodorski@automate.com>)
Список pgsql-jdbc
I had this problem, too.  I solved it by mapping my id column as a sequence instead of as 'identity'

        <id name="id" type="int" column="application_id">
            <generator class="sequence">
                <param name="sequence">portal.applications_application_id_seq</param>
            </generator>
        </id>

You could probably get away with creating the table with a serial column and just passing in the sequence that postgres implicitly uses, but I thought it safer to just explicitly declare the sequences that are used for ids.  This does mean that inserts require two queries, since there is no way to get the generated id in the same statement that does the insert, but I don't do bulk inserts via hibernate, so it doesn't much matter in my case.  

I'd definitely prefer to have cleaner mappings and not have to manually create/maintain the sequences, but this isn't the end of the world.  This is a pretty huge bug to have existed in the codebase for so long, though.  Personally, I never even reported it, as I thought it must be some kind of configuration error on my part since I didn't find any reference to the problem via google back when I looked (it was a while back - I was using pg 8.3.x at the time).


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

Предыдущее
От: Adam Todorski
Дата:
Сообщение: Re: getGeneratedKeys() problem
Следующее
От: Emanuel Freitas
Дата:
Сообщение: Exception in DriverManager.getConnection creates multiple connections in SYN_SEND state