object references an unsaved transient instance : save the transient instance before flushing
The TransientObjectException
comes whenever you try to save the Object without saving the appropriate Joins.You have to save the UserInfoEntity
first and afterwards you can save your PlayerInfoEntity
class.
player.setUserId(new UserInfoEntity());
By using this you are assigning particular UserInfoEntity
to PlayerInfoEntity
. But UserInfoEntity
does not have any ID. How would both get mapped ? That is why the exception is coming.
Hope it would help you.
You should use the CascadeType.PERSIST or CascadeType.ALL