I have the following scenario: I´ve got a user-object that gets it´s ID through a @SequenceGenerator. Inside this user-object I´ve got an object VerificationCode. The ID of the VerificatinCode should be the same as the ID of the user, but the problem is, that I receive the id only while persisting, so I cannot instantiate the VerificationCode with a User-object and use it´s id with my getId()-method. One solution I found was to use the @PrePersist and do a MyVerificationObject.setId(myUserObject.getId()) in this method. But is this the way to go or is there a more elegant (object-oriented) way?
noone knows about a solution to this?
is this so unusual? or is it too obvious?