java Hibernate 遵循哪种模式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1308096/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which pattern does Hibernate follow?
提问by yuos
In his book "Patterns of Enterprise Application Architecture", Martin Fowler talks about persistence patterns which are commonly found in software development and particularly in relation to ORMs.
在他的“企业应用程序架构模式”一书中,Martin Fowler 谈到了软件开发中常见的持久性模式,尤其是与 ORM 相关的持久性模式。
Is there a pattern that Hibernate adheres to most closely?
有没有 Hibernate 最遵循的模式?
回答by dfa
Hibernate make use of several patterns:
Hibernate 使用了几种模式:
- Lazy load(proxing collections)
- Unit of Work(as part of Session object)
- probably Identity Mapor something more sophisticated
- Mapping Metadata
- Query Objectfor Criterion API
- all object relational structual patterns
- 延迟加载(代理集合)
- 工作单元(作为 Session 对象的一部分)
- 可能是身份地图或更复杂的东西
- 映射元数据
- Criterion API 的查询对象
- 所有对象关系结构模式
回答by Joshua Partogi
Hibernate does not follow ActiveRecord pattern. The pattern that Hibernate adheres most closely is the Datamapperpattern.
Hibernate 不遵循 ActiveRecord 模式。Hibernate 最坚持的模式是Datamapper模式。
回答by Juliet
If you're looking for design patterns explicity, then you could consider Hibernate a fancy API for implementing the Active Record Pattern:
如果您正在寻找明确的设计模式,那么您可以考虑将 Hibernate 视为实现Active Record Pattern的奇特 API :
In software engineering, the active record pattern is a design pattern frequently found in software that stores its data in relational databases. It was named by Martin Fowler in his book Patterns of Enterprise Application Architecture. The interface to such an object would include functions such as Insert, Update, and Delete, plus properties that correspond more-or-less directly to the columns in the underlying database table.
Active record is an approach to accessing data in a database. A database table or view is wrapped into a class; thus an object instance is tied to a single row in the table. After creation of an object, a new row is added to the table upon save. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The wrapper class implements accessor methods or properties for each column in the table or view.
在软件工程中,活动记录模式是一种常见于将数据存储在关系数据库中的软件中的设计模式。它由 Martin Fowler 在其著作 Patterns of Enterprise Application Architecture 中命名。此类对象的接口将包括诸如插入、更新和删除之类的函数,以及与底层数据库表中的列或多或少直接对应的属性。
活动记录是一种访问数据库中数据的方法。一个数据库表或视图被包装成一个类;因此,对象实例绑定到表中的单行。创建对象后,保存时将新行添加到表中。任何加载的对象都从数据库中获取其信息;当一个对象被更新时,表中相应的行也被更新。包装类为表或视图中的每一列实现访问器方法或属性。
回答by duffymo
Hibernate is obviously domain model. The objects in ORM are the domain model, so you can't do ORM without it.
Hibernate 显然是领域模型。ORM 中的对象是领域模型,所以没有它你就不能做 ORM。

