Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top