Partitioning in DDL

Hello dear Hibernate community,

We have a huge table, that we want to partition by range (we’re using postgres).
This is possible via CREATE TABLE instruction in Postgres, e.g.:

CREATE TABLE my_table (
    id uuid NOT NULL,
    date_time timestamptz(6) NULL,
) PARTITION BY RANGE (date_time);

We’re only using hbm2ddl to generate ddl instructions, and we’d like to generate the PARTITION BY RANGE clause with the help of hbm2ddl! I’ve seen the discussion on this topic and a ticket in jira.

At the moment, there doesn’t appear to be an annotation available to achieve this. Could you please recommend us any workaround? Maybe, for instance, there’s some hook that we would use to append PARTITION BY RANGE to the generated CREATE TABLE instruction (or something like that)?

Thanks in advance.

There is no way to do this with Hibernate ORM yet, because there was no user demand so far.
You should be using a schema management tool like Liquibase or Flyway though.

You could try to hack it yourself by providing a custom TableExporter via a custom Dialect, but you should use a schema management tool anyway.

Thanks for the response. We’ve added our use-case to the discussion.