there is some trickery going on in the background here. Although the ID is initially set to a random value (necessary for backwords compatibility purposes), it is overridden in an @PostLoad method (performPostLoadInitialization) to the value provided by the database.
So, although perhaps not super-optimal, it will work like expected.
Hmm… never thought of that one. Is there an @PostLoad alternative to Hibernate? In fact, all you need to do is make sure the “performPostLoadInitialization” method is called after loading the aggregate from the DB.