HHH-8683 EntityEntry backport on master

Hey @gunnarmorling and @sanne
I had to make a few adjustments to port it to master, can you double check it.
(new pull request on the correct repo)
I think my point is that it would be nice to standardise on a serialisation output rather than expect a serialised format different between implementations. It does not matter much if an optimised implementation is deserialised in a non optimised one. We anticipate this code path to be rarely used if any.