Double persist or merge of entity

Hibernate saves the same record twice, but the funny thing is it doen’t happen all the time. I have been battling with it for days now. Any help will be appreciated. Thanks you

You need to replicate the issue using a test case like this one.

This kind of issues might be caused because bidirectional associations are not properly synchronized or collections being recreated instead of adding/removing/updating entries.

You need to activate the log and correlate the SQL queries with the application-level log and the thread identifier to know which code triggers the duplicated statements.

But I’m not using cascade on the relationship. It doesn’t happen all the time but once a while. When it happens all the entities involved the transaction will have double entries instead of single entry

Logging will help you understand where and why it happens.