7

I'm reading up on OOP design patterns and framework design and find myself a bit unshure about the difference between the terms ORM and Persistence framework. Is an ORM a type of PF? What are the different features you can expect of the two?

Alex
  • 14,104
  • 11
  • 54
  • 77

2 Answers2

5

I would define ORM as a system to map any data to the object/class structure. That data may come from a system that is aimed to be for persist data, but not mandatory. Imagine a JSON mapper that reads data from a network service into an object.

A persistence framework mostly uses ORM to interface to user code and covers the problematic to make the storage of objects as secure and reliable as possible.

ORM is more generic term than persistence. ORM may live without Persistence but not vicecersa.

PeterMmm
  • 24,152
  • 13
  • 73
  • 111
  • 1
    But, doesn't the M in ORM stand for "relational"? as in relational database? – Tulains Córdova Sep 04 '16 at 04:38
  • Can you please explain the persist(as a verb)? So when i translate the persist and persistence words to my language, i didn't find convenient meaning about that as a dependent meaning of ORM concept. – sopehl Feb 11 '20 at 07:27
  • Hi ORM is Object Relational Mapping, and the verb persist means store on a non-volatile medium, for example, "I have persisted the changes I made to the hard disk", or "Databases persist information to secondary storage for safe keeping and reference". – gouderadrian Jan 07 '21 at 08:53
3

ORM refers to the concept of Object Relational Mapping, that is the act of mapping records in a database (which may come from tables or views for example) to their object representation in an application (entity) or collections of entities together with their relationships.

Persistence Frameworks refer to frameworks that persist (store) data , normally into a database. Note that a persistence framework may persist to anything in reality, depending on the framework, even to an XML file for example. It is an abstraction layer between the database and the entities in an application.

Sometimes these terms are used interchangeably. Note that good persistence frameworks have their own rules of how to extract data, how to persist it,how to deal with what is called the impedance mismatch (look it up in Wiki), how to manage stale or dirty data in a predefined way, how to load data and related data, and so on and so forth.

gouderadrian
  • 361
  • 4
  • 11