In the database, we (generally) have the numeric ID and entity type. How do we construct an ItemId from that?
See the code ;) Serialization was already encapsulated, so only some local
changes are needed for this. Users in general do not know about the db
serialization format.
The serialization format is an external, canonical representation. The database form is internal and may change. Isn't that the reason we also have two JSON representations for entities?