From: Freddie Burgess <fburgess@radiantblue.com>
To: 'Jaime Casanova' <jaime@2ndquadrant.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: Postgres Partitions not working with hibernate 4.1.6.Final
Date: Tue, 25 Sep 2012 17:34:20 -0400
Message-ID: <001501cd9b65$866b6600$93423200$@radiantblue.com> (raw)
In-Reply-To: <CAJKUy5i6_pxNmvzu+JTXaoWy3eEynNFdrOnGdNPPoh1XbeZmQA@mail.gmail.com>
References: <000801cd9b5a$12717600$37546200$@radiantblue.com>
<CAJKUy5i6_pxNmvzu+JTXaoWy3eEynNFdrOnGdNPPoh1XbeZmQA@mail.gmail.com>
Hi Jaime,
We have our partitioning setup exactly like the instructions in
ddl-partitioning.html and prior to the upgrade to Hibernate 4.1.6 ingest was
working flawlessly as long as we set the
hibernate.jdbc.factory_class=im.empl.core.service.ingest.postgres.PostgresPa
rtitionBatcherFactory in Hibernate. If we comment out this setting in our
old configuration using Hibernate 3.2.2.GA inserts into our partitioned
tables breaks as well.
I'm not sure how org.hibernate.jdbc.Batcher is affecting partition inserts.
I previously omitted the return call to the PostgresPartitionBatcher module
component to the batcher process.
package im.empl.cores.service.ingest.postgres;
import java.lang.reflect.Field;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.batch.spi.Batch;
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
import org.hibernate.engine.jdbc.batch.spi.BatchObserver;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
public class PostgresPartitionBatcher implements Batch
{
private static Logger logger =
Logger.getLogger("PostgresPartitionBatcher");
protected void doExecuteBatch() {
try {
/*
* use reflection to access the private field of the
super class
* ugly but necessary
*/
Field field =
this.getClass().getSuperclass().getDeclaredField(
"batchSize");
field.setAccessible(true);
int batchSize = field.getInt(this);
if (batchSize != 0) {
try {
// ps.executeBatch();
}
catch (RuntimeException re) {
throw re;
}
finally {
batchSize = 0;
field.setInt(
this,
batchSize);
}
}
}
catch (Exception e) {
logger.error("Batch execution failed.", e);
throw new HibernateException(
"Unable to execute batch.");
}
}
@Override
public void addObserver(BatchObserver arg0) {
// TODO Auto-generated method stub
}
@Override
public void addToBatch() {
// TODO Auto-generated method stub
}
@Override
public void execute() {
// TODO Auto-generated method stub
}
@Override
public PreparedStatement getBatchStatement(String arg0, boolean
arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public BatchKey getKey() {
// TODO Auto-generated method stub
return null;
}
@Override
public void release() {
// TODO Auto-generated method stub
}
}
-----Original Message-----
From: jcasanov@systemguards.com.ec [mailto:jcasanov@systemguards.com.ec] On
Behalf Of Jaime Casanova
Sent: Tuesday, September 25, 2012 4:50 PM
To: Freddie Burgess
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] Postgres Partitions not working with hibernate
4.1.6.Final
On Tue, Sep 25, 2012 at 3:12 PM, Freddie Burgess <fburgess@radiantblue.com>
wrote:
>
> Does anyone know why the previous .jdbc.batcher logic managed the
> postgres partitioned inserts without any issues?
> Are there any other alternative that will allow us to insert into a
> Postgres partition table without making massive code changes?
don't know about hibernate or that strange way to insert into partitions.
the postgresql's way is to create triggers on parent table to route the
inserts into the partitions as described here:
http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html> Would upgrading from 4.1.6.Final to Hibernate 4.1.7 in Linux, fix this
> partitioning ingest problem?
>
don't know, but that certainly looks like a hibernate bug, not a postgresql
one
--
Jaime Casanova www.2ndQuadrant.com
Professional PostgreSQL: Soporte 24x7 y capacitación
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: fburgess@radiantblue.com, jaime@2ndquadrant.com
Subject: Re: Postgres Partitions not working with hibernate 4.1.6.Final
In-Reply-To: <001501cd9b65$866b6600$93423200$@radiantblue.com>
References: <000801cd9b5a$12717600$37546200$@radiantblue.com> <CAJKUy5i6_pxNmvzu+JTXaoWy3eEynNFdrOnGdNPPoh1XbeZmQA@mail.gmail.com> <001501cd9b65$866b6600$93423200$@radiantblue.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox