I had a similar problem when I found an alternative solution, but maybe this is not the best practice.
Now, since the display is dependent on roomId , create the Room constructor (type roomId) and set the bean before saving the bean transaction . Therefore, you need to get data from the database. What hibernation cares about Identity, what it needs to display beans.
I used this approach to get data, and I hope that you do not want the Room to be updated when updating the Transaction . So set insert, update the mapping properties to false.
source share