Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between an ORM and a Persistence framework?

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?

like image 841
Alex Avatar asked Mar 29 '11 07:03

Alex


2 Answers

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.

like image 92
PeterMmm Avatar answered Oct 15 '22 07:10

PeterMmm


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.

like image 40
gouderadrian Avatar answered Oct 15 '22 07:10

gouderadrian