Data access patterns
The PoEAA data source and object-relational patterns, and the related data access patterns. ORMs as libraries are in data-and-persistence/orms.
Concepts
- Object-relational impedance mismatch
The set of differences between objects in memory and rows in relational tables, in granularity, subtypes, identity, associations and navigation, that make the mapping between them hard.
core
Patterns
- Active Record
An Active Record is an object that wraps one row of a table. It holds the data of the row, the code that reads and writes the row, and the domain logic on that data.
core - Association Table Mapping
An Association Table Mapping saves a many-to-many association between objects as a separate link table, in which each row holds the keys of one pair of linked rows.
core - Class Table Inheritance
Class Table Inheritance stores an inheritance hierarchy with one table for each class, so an object is spread over the tables of its class and of each class above it, joined by one key.
core - Concrete Table Inheritance
Concrete Table Inheritance stores an inheritance hierarchy with one table for each concrete class, and each table has columns for all the fields of its class, the inherited ones too.
core - Data Mapper
A Data Mapper is a layer that moves data between domain objects and a database. The objects know nothing of the database, and the database knows nothing of the objects.
core - Data access object
A data access object puts all access to one kind of stored data behind an interface of persistence operations, so that business code does not depend on the storage.
core - Embedded Value
An Embedded Value saves a small value object, such as an amount of money or a date range, in columns of its owner's table instead of in a table of its own.
core - Foreign Key Mapping
A Foreign Key Mapping saves a reference from one object to another as a foreign key column that holds the key of the other object's row, and turns the key back into a reference on load.
core - Identity Field
An Identity Field stores the primary key of a database row in a field of the object that holds the row's data, so the program can find the row again to update or delete it.
core - Identity Map
An Identity Map keeps each object that a session loads from the database in a map by its key, so that one row has only one object in memory and is not loaded twice.
core - Lazy Load
A Lazy Load is an object that does not hold all of its data yet but knows how to get it, so a related object is read from the database only when the program first uses it.
core - Query Object
Query Object represents a database query as a structure of objects that name classes and fields, and the structure writes itself as SQL with the columns from the mapping metadata.
core - Repository pattern
A repository gives the domain code a collection-like interface to stored objects, such as add, get and find by criteria, and hides the database queries and the mapping behind it.
core - Row Data Gateway
A Row Data Gateway is an object for one row of a table. It has one field for each column and methods to insert, update and delete its row, and it has no business logic.
core - Single Table Inheritance
Single Table Inheritance stores all the classes of an inheritance hierarchy in one table, with a column for each field of each class and a type column that names the class of each row.
core - Table Data Gateway
A Table Data Gateway is one object that holds all the SQL for one table or view. Its methods find, insert, update and delete rows, and they return plain data, not domain objects.
core - Unit of Work
A Unit of Work records the objects that a business transaction adds, changes and removes, and then writes all the changes to the database in one short transaction.
core - Database access layer
A database access layer puts all database access of an application in one layer, with a logical part that the application uses and a physical part that knows the tables.
advanced - Dependent Mapping
In Dependent Mapping, the mapper of an owner class also loads, saves and deletes the child objects that belong only to that owner, such as the tracks of an album.
advanced - Inheritance Mappers
Inheritance Mappers organizes the mappers of a class hierarchy: one mapper for each class maps the fields that the class declares, and one mapper for the hierarchy chooses the concrete mapper.
advanced - Metadata Mapping
Metadata Mapping holds the mapping between fields and columns as data, and generic code, by reflection or by generated code, reads it to load, insert and update objects.
advanced - Serialized LOB
Serialized LOB saves a graph of objects as one serialized value, such as JSON or a binary blob, in one column of a table, instead of as rows of related tables.
advanced