How to save only one entity and not its associated entities?

Business scenario:
I want to save data to another database schema when the data is deleted, I use listeners.
When I insert the data into another database, hibernate tells me that no associated entity exists.

For example, in the main database, the user id is 1 and the associated role id is also 1. When user 1 is deleted, saving user 1 to another empty database will report an error. How can I save only the user and not the role?

I don’t know how your code looks like, but usually by setting the role association to null in your code.

I have 2 data sources and 2 entitymanager, one needs to associate role and one doesn’t

Then copy the object. I don’t understand the problem here.