Hibernate与MongoDB [英] Hibernate with MongoDB

查看:173
本文介绍了Hibernate与MongoDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找资源,展示如何将MongoDB与Hibernate集成(最好在Spring中),以便我可以在RDBMS和NoSql之间切换:有没有人有过这样的经验?

解决方案

你不能轻易做到这一点。 Hibernate的重点是将Java对象映射到关系数据库。尽管Hibernate抽象了很多细节,但仍需要了解关系数据库如何处理诸如外键和主键之类的事情以及您运行的查询的性能影响。 MongoDB需要一种完全不同的设计数据库的方式,专注于对象而不是列和表。虽然你可以为MongoDB创建一个Hibernate方言,创建一个可以在关系型数据库和NoSql数据库上工作的设计,但是会给你一个设计效果不理想。


I'm looking for resources showing how to integrate MongoDB with Hibernate (preferably from within spring) so that I can switch between a RDBMS and a NoSql alternative: does anyone have experience doing this?

解决方案

You can't easily do this. The point of Hibernate is to map Java Objects to a relational database. Although Hibernate abstracts a lot of details away you still need to understand how relational databases work with things such as foreign and primary keys, and the performance implications of queries you run. MongoDB requires an entire different way of designing your database focusing on objects instead of columns and tables. while you may be able to create a Hibernate dialect for MongoDB creating a design that would work on both a relational database and a NoSql database will give you a design that works poorly on both.

这篇关于Hibernate与MongoDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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