从现有数据库生成JDO对象 [英] Generate JDO objects from existing database

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

问题描述

是否有工具从现有数据库生成JDO对象?我更喜欢一个看起来很棒的Eclipse插件,我可以使用它来生成和维护对象,但似乎这个目前还不存在。是否有其他简单的工具来生成数据库对象?

Is there a tool to generate JDO objects from an existing database? I prefer a awesome looking Eclipse plugin which i could use to generate and maintain the object but it seems that this is currently not existing. Are other, simple tools to generate the database objects?

推荐答案

JDO对象不是围绕数据库行的简单包装器(尽管你可以将JDO对象实现为数据库行的简单包装器,如果这样的话是你想要的)。因此,大多数自动化工具只会通过查看数据库而不知道如何呈现对象。

JDO objects are not simple wrappers around database rows (although you can implement your JDO objects as simple wrappers around database rows if that is what you wish). As such, most automated tools will not know how the object is to be presented by only looking at the database.

例如,对象如:

public class Person {

   private List<PhoneNumber> phoneNumbers;

   ...

   public List<PhoneNumber> getPhoneNumbers() {
     ...
   }

}

可能会让JDO预取所有电话号码以直接包含在对象中。在关系数据库中,这可能是通过在构造Person对象时将PhoneNumber数据库表与Person数据库表连接来完成的。

might have JDO pre-fetching all the phone numbers for direct inclusion into the object. In the relational database this would probably be done by joining the PhoneNumber database table with the Person database table when constructing the Person object.

其他实现可能看起来像

public class PhoneNumber {

   public Person getPerson() {
     ...
   }
}

并强制用户在单独的数据库请求中获取某人的电话号码。通用工具无法预测您希望使用哪种方式。有两个选择(如此处所示),很容易说让它可配置!但是,在组合添加八个或更多独立选项后,不清楚配置类生成会更容易(而不是直接编写类)。

And force the user to fetch a person's phone numbers in a separate database request. It's just not possible for a general purpose tool to predict which manner you wish to use. With two choices (as presented here) it's pretty easy to say "make it configurable!" However, after you add eight or more independent choices in combination, it is not clear that it would be easier to configure the class generation (as opposed to writing the class outright).

更不用说JDO不是为了类生成而设计的,事实上它的设计是为了让你的手写类持久而不生成,因为当时的类生成技术留下了很多可见的错误(不合需要的命名模式,暴露冲突的接口和方法等。)

Not to mention that JDO wasn't designed for class generation in mind, in fact it was designed to make your hand written classes persistent without generation because the class generation technologies of the day left a lot of visible cruft (undesirable naming patterns, exposed conflicting interfaces and methods, etc).

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

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