为现有数据库使用Hibernate [英] Using Hibernate for Existing Database

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

问题描述

我们有一个已经运行了很长时间的应用程序。现在我们将它迁移到Spring,并可能使用Hibernate或任何其他ORM。



但我们遇到了一个问题。是不是推荐/不好的想法,使用Hibernate的已经存在的数据库和模型对象模式?



大多数人主张不使用Hibernate,而是与其他人一起去像iBatis这样的ORM。但在我们公司中,所有人都是Hibernate的支持者。



有什么经验?

解决方案

我会说,选择Hibernate,iBatis或其他任何不知道你的需求的东西是不负责任的。



如果你没有一个坚实的对象模型,我会说Hibernate是一个糟糕的选择。



如果你使用存储过程作为数据库的接口,我会说Hibernate是一个糟糕的选择。 / p>

如果您不喜欢Hibernate为您生成的动态SQL,我会说Hibernate是一个糟糕的选择。



明白吗?像那些来自Hibernate支持者的膝反应反应并不是一个好主意。

可能是iBatis或Spring JDBC模板比Hibernate更好。你应该对这个决定有更多的了解,并为你的应用做好准备,而不是盲目地听一个暴徒。



你不必全部或全都不知道,要么。可以用一种技术来实现你的解决方案的一部分,其余的可以用另一种技术来实现。



我建议制作基于持久层的接口,以便在不影响实现的情况下进行交换客户。


We have an application thats already running for a long time. Now we are migrating it to Spring and possibly using Hibernate or any other ORM.

But we caught up with a question. Is it not recommended / bad idea to use Hibernate for the already existing Database and model the object around Schema?

Most people advocate NOT using Hibernate and instead of go with some other ORMs like iBatis. But in our company, all are proponents of Hibernate.

Any experiences?

解决方案

I would say that it's irresponsible to choose Hibernate, iBatis, or anything else without knowing your requirements.

If you don't have a solid object model, I'd say that Hibernate is a terrible choice.

If you use stored procedures as the interface to your database, I'd say that Hibernate is a terrible choice.

If you don't like the dynamic SQL that Hibernate generates for you, I'd say that Hibernate is a terrible choice.

Get it? Knee-jerk reactions like the ones from those Hibernate proponents aren't a good idea.

It might be that iBatis or Spring JDBC template is a better choice than Hibernate. You ought to become more informed about that decision and make it for your application rather than blindly listen to a mob.

You don't have to be all or none about it, either. It's possible to implement part of your solution with one technology and the rest in another.

I'd recommend making your persistence layer interface-based so you can swap implementations without affecting clients.

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

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