ORM / How to deal with the correspondence between Domain object and Persistent object?

后端 未结 1 1829
清酒与你
清酒与你 2021-01-20 18:41

In an application, there are at least two ways for dealing with domain object persistence and an ORM.

  • Mapping directly the domain object to persistence using s
1条回答
  •  [愿得一人]
    2021-01-20 19:39

    I disagree with the linked article. While I agree that the concerns between the domain model and the persistence model are different, the entire purpose of an ORM is to map between a domain model and a persistence model. Since the ORM is supposed to provide that mapping, creating an additional class hierarchy to facilitate mapping is overkill and can lead to problems like the one you're describing. The fact that the domain model resembles the data model is indeed far more than a mere coincidence. Instead, they are both representing aspects of the same domain and should therefore have a high degree of correspondence. The ORM is designed to address the mismatch between an object model and a corresponding relational model. There are cases where mapping gets tough, but in NHibernate for example, these can be addressed by implementing custom user types for component mappings.

    0 讨论(0)
提交回复
热议问题