Browse OOP reference
Modelling and persistence

What is an entity?

On this page

An entity has a domain identity that survives changes to its attributes. A library copy can change shelf, condition and borrower while retaining its accession number. Loading the same copy twice may create distinct runtime objects that refer to one domain entity.

Worked example

Python
from dataclasses import dataclass

@dataclass
class Copy:
    accession: int
    shelf: str

first = Copy(72, "A")
reloaded = Copy(72, "B")
assert first is not reloaded
assert first.accession == reloaded.accession

Python data classes

Explore class relationships in the OOP Playground

What is an object?What are value objects?What is the object-relational impedance mismatch?

All OOP questions

Search ObjectFAQ