数据库不可知应用程序 [英] Database Agnostic Application

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

问题描述

我正在处理的应用程序的数据库尚未被商家确认。

The database for one the application that I am working on is not confirmed yet by the business.


  • 最好的猜测是Oracle和DB2 。

  • 我听说的是最初的项目将使用DB2 V9和Oracle 11g。

我们为这个项目使用Spring 3.0.5,Hibernate 3.5,JPA2和JBoss 5.

We are using Spring 3.0.5, Hibernate 3.5, JPA2 and JBoss 5 for this project

那么,这里进入构建阶段的最佳做法是什么和测试阶段?

So what are the best practices here going into the build phase and test phase?


  1. 我是先使用DB2构建,然后再担心Oracle(这个
    不正确)?

  2. 或者,我应该使用JPA(Hibernate)和
    编写,然后生成数据库模式吗?

  3. 还是别的什么?

DB,什么和什么时候,因为这些是坐在漂亮的房间里的人的战略决策,得到胖的支票和大奖金。

PS: I've no control over the choice of the DB, what and when, as these are strategic decision made by people sitting in nice rooms getting fat cheques and big bonuses.

谢谢,
Adi

Thanks, Adi

推荐答案

如果您正在编写应用程序数据库不可知,您将失去对数据库特定功能的访问权限。除了JPA和Hibernate所做的自动优化之外,数据库还减少了常见的功能。你必须设置一些东西为自动和信任JPA / Hibernate做你可以专门设置,如果你知道数据库(例如id生成器策略)。

Obviously you are loosing the access to specific features of the database if you are writing your application database agnostic. The database is, except for automatic optimizations done by JPA and Hibernate, reduced to common features. You have to set some things to automatic and trust JPA/Hibernate to do it right that you could set specifically if you knew the database (e.g. id generator strategies).

但是看起来数据库的特定开发者特征与决定无关,因此它们不能与应用程序相关。其他原因可能影响决定(如价格,金钱,现金,个人关系,管理工具,硬件要求,现有知识和人物)。

But it seems that the specific developer features of the database are not relevant for the decision so they can't be relevant to the application. What other reasons may influence the decision (like price, money, cash, personal relations, management tools, hardware requirements, existing knowledge and personell) can only be speculated about.

所以IMHO你没有选择。严格避免任何数据库特定。这包括让JPA / Hibernate生成模式(你的要点#2)。在这个项目设置中,你不应该手动修改数据库。

So IMHO you don't have a choice. Strictly avoid anything database specific. That includes letting the JPA/Hibernate generate the schema (your point #2). In this project setup you shouldn't tinker with the database manually.

好吧...可悲的是,在JPA / Hibernate开发中有一些隐藏的陷阱,例如对数函数不被一起映射)。所以你应该从第一天开始对所有可能的数据库运行所有的测试。当你写最好的猜测是...你应该抓住任何数据库可用并测试它。应该很容易设置给定的堆栈。

Well... sadly there ARE some hidden traps in JPA/Hibernate developement that make it database dependent (e.g. logarithmic functions are not mapped consistenly). So you should run all your tests against all possible databases from day one. As you write "Best guess is..." you should just grab any database available and test against it. Should be easly setup with the given stack.

如果可能的话,你应该尝试加速关于数据库的决定。

And you should try to accelerate the decision about the database used, if possible.

这篇关于数据库不可知应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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