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
Pythonfrom 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.accessionExplore class relationships in the OOP Playground