Database sharding and JPA

2020-06-09 07:04发布

问题:

I am working on a Java application that requires horizontal partitioning of data in different PostgreSQL servers. I would like to use a JPA framework and Spring for transaction management.

The most popular frameworks for sharding data with JPA seem to be Hibernate Shards, which appears to be no longer in development, and OpenJPA Slice, which does not support virtual shards (one of my requirements). Are there any other options that I'm missing, or a way to get around the OpenJPA limitation?

Thanks in advance for your input!

回答1:

You can have a look at Sharding-JDBC, it is a JDBC driver for shard databases and tables, can adapter for any ORM frameworks.



回答2:

Have you looked into EclipseLink? It supports JPA2 and horizontal sharding.

The documentation says it supports Sharding over multiple database instance