Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA or Hibernates With Oracle Table Partitions?

I need to use an Entity framework with my application, and I have used table - partitions in Oracle database. With simple JDBC, I am able to select data from a specific partition. But I don't know whether I can do the same with hibernate or Eclipse link (JPA). If someone knows how to do that, please do let me know.

usually the select statement in JDBC - SQL is,

select * from TABLE_NAME partiton(PARTITON_NAME) where FIELD_NAME='PARAMETER_VALUE';

How can I do the same with Hibernates or JPA?

Please share at least a link for learning sources.

Thanks!!!

like image 379
Chathura Kulasinghe Avatar asked Sep 13 '10 11:09

Chathura Kulasinghe


People also ask

Does table partitioning improve performance Oracle?

Partitioning offers these advantages: Partitioning enables data management operations such data loads, index creation and rebuilding, and backup/recovery at the partition level, rather than on the entire table. This results in significantly reduced times for these operations. Partitioning improves query performance.

Can we use JPA with Hibernate?

No, you cannot perform CRUD operations with JPA alone. As JPA is just a specification, you need the implementation to perform database operations. The implementations are provided by Hibernate, EclipseLink, Ibatis, etc.

Does JPA need hibernate?

Hibernate provides a reference implementation of the Java Persistence API that makes it a great choice as an ORM tool with the benefits of loose coupling. Remember, Spring Data JPA always requires the JPA provider such as Hibernate or Eclipse Link.


1 Answers

JPA or any other ORM framework does not support Oracle partition tables natively (atleast in my knowledge).

There are different possible solutions though, depending on the nature of your problem:

  • Refactor your classes so that data that needs to be treated differently in real-life, belongs in a separate class. Sometimes this is called vertical partitioning (partitions are not obtained across rows, rather across columns).
  • Use Oracle partition tables underneath and use native SQL queries or stored procedures from JPA. This is just a possibile solution (I haven't attempted this).
  • Use Hibernate Shards. Although the typical use case for Hibernate Shards is not for a single database, it presents a singular view of distributed databases to an application developer.

Related:

  1. JPA Performance, Don't Ignore the Database
like image 176
Vineet Reynolds Avatar answered Oct 04 '22 10:10

Vineet Reynolds