自动生成数据访问层
Hibernate 和 eclipselink 是最流行的 Java DAL 框架。据我了解,它们将程序员创建的对象映射到自动创建的数据库关系和存储过程。
使用此方法与以下方法相比有何优缺点:
编写您自己的 DAL,假设我的项目是中小型。
寻找一个框架(如果存在?)以另一种方式 - 从数据库关系和存储过程创建类。
就我个人而言,我觉得推理数据库关系比推理 Java(或任何编程语言)类更舒服。
Hibernate and eclipselink are the most popular DAL frameworks for Java. From what I understand they map object that the programmer created to database relations and stored procedures that are created automatically.
What are the pros and cons of using this method versus:
Writing your own DAL, assuming my project is small-medium sized.
Finding a framework (if exists ?) that will it the other way - create classes from database relations and stored procedures.
Personally, I feel more comfortable with reasoning about database relations rather than Java (or any programming language) classes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你对JPA的理解是错误的。 JPA(其中 Hibernate 和 EclipseLink 是两个实现)是一个 ORM:对象关系映射器。有些人更喜欢设计 Java 对象并从这些对象推断数据库模式。其他人更喜欢设计数据库模式,并从该模式推导出 Java 对象。
这两种方法都是可能的,并且 JPA 不采用任何一种方法。它指定 Java 对象及其关联如何/必须映射到表。
与编写自己的 DAL 相比,优点是:
使用寻找一个从数据库关系创建类的框架:
Your understanding of JPA is wrong. JPA (of which Hibernate and EclipseLink ar two implementations) is an ORM: Object Relational Mapper. Some prefer designing Java objects and deduce the database schema from these objects. Others prefer designing a database schema, and deduce Java objects from this schema.
Both approaches are possible, and JPA doesn't assume any of those approaches. It specifies how Java objects and their associations can/must be mapped to tables.
Advantages over writing your own DAL:
Advantages over finding a framework which creates classes from database relations: