BUG #8027: Get generated key value while inserting in partitioned table

From: mohansammeta(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8027: Get generated key value while inserting in partitioned table
Date: 2013-04-02 07:11:27
Message-ID: E1UMvNP-0002z1-Fr@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8027
Logged by: mohan sammeta
Email address: mohansammeta(at)gmail(dot)com
PostgreSQL version: 8.4.0
Operating system: ubuntu
Description:

Hi I have a table in Postgres, say email_messages. It is partitioned so
whatever the inserts i do it using my java application will not effect the
master table, as the data is actually getting inserted in the child tables.
Here is the problem, I want to get an auto generated column value (say
email_message_id which is of big serial type). Postgres is returning it as
null since there is no insert being done on master table. For oracle I used
GeneratedKeyHolder to get that value. But I'm unable to do the same for
partitioned table in postgres. Please help me out.

Here is the code snippet we used for oracle

public void createAndFetchPKImpl(final Entity pEntity, final String
pStatementId, final String pPKColumnName) {

final SqlParameterSource parameterSource =
new BeanPropertySqlParameterSource(pEntity);

final String[] columnNames = new String[]{"email_message_id"};
final KeyHolder keyHolder = new GeneratedKeyHolder();
final int numberOfRowsEffected = mNamedParameterJdbcTemplate.update(
getStatement(pStatementId), parameterSource, keyHolder, columnNames);
pEntity.setId(ConversionUtil.getLongValue(keyHolder.getKey()));

}
We are using spring 3.1.1.
I am getting numberOfRowsEffected as zero and keyHolder.getKey() as null
even though the insert is happening in the table.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sandeep Thakkar 2013-04-02 08:45:33 Re: BUG #7985: Postgres Windows Installer fails with "permission denied"
Previous Message jevgeni.virves 2013-04-01 16:57:29 BUG #8026: pgAdmin III FATAL: Cannot open the logfile!