Which pattern does Hibernate follow?

后端 未结 4 1936
野的像风
野的像风 2020-12-14 17:10

In his book \"Patterns of Enterprise Application Architecture\", Martin Fowler talks about persistence patterns which are commonly found in software development and particul

相关标签:
4条回答
  • 2020-12-14 17:48

    Hibernate does not follow ActiveRecord pattern. The pattern that Hibernate adheres most closely is the Datamapper pattern.

    0 讨论(0)
  • 2020-12-14 17:48

    If you're looking for design patterns explicity, then you could consider Hibernate a fancy API for implementing the Active Record Pattern:

    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.

    0 讨论(0)
  • 2020-12-14 17:54

    Hibernate is obviously domain model. The objects in ORM are the domain model, so you can't do ORM without it.

    0 讨论(0)
  • 2020-12-14 17:58

    Hibernate make use of several patterns:

    • Lazy load (proxing collections)
    • Unit of Work (as part of Session object)
    • probably Identity Map or something more sophisticated
    • Mapping Metadata
    • Query Object for Criterion API
    • all object relational structual patterns
    0 讨论(0)
提交回复
热议问题