JPA或休眠与Oracle表分区? [英] JPA or Hibernates With Oracle Table Partitions?

查看:104
本文介绍了JPA或休眠与Oracle表分区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在应用程序中使用实体框架,并且在Oracle数据库中使用了表分区。使用简单的JDBC,我可以从特定的分区中选择数据。但我不知道我是否可以用hibernate或Eclipse链接(JPA)做同样的事情。如果有人知道如何做到这一点,请让我知道。

通常是JDBC中的select语句--SQL是,

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

我怎样才能与Hibernates或JPA做同样的事情?



请分享至少一个学习资源的链接。



感谢!!!

解决方案

JPA或任何其他ORM框架根本不支持Oracle分区表(至少据我所知)。

尽管存在不同的可能解决方案,但取决于问题的性质:




  • 重构您的类,以便在实际生活中需要区别对待的数据属于单独的类。有时这称为垂直分区(分区不是跨行而是跨列获得的)。
  • 在下面使用Oracle分区表并使用JPA的本机SQL查询或存储过程。这只是一个可能的解决方案(我没有尝试过)。

  • 使用 Hibernate Shards 。虽然Hibernate Shards的典型用例不适用于单个数据库,但它向应用程序开发人员展示了分布式数据库的单一视图。



相关


  1. JPA性能,不要忽略数据库


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!!!

解决方案

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

这篇关于JPA或休眠与Oracle表分区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆