JBoss 4.0.5, MySql 5.0, WindowsXP
I have medium sized applicated with about 50 entities with relations. I have used inheritence and total number of tables are same as entities. Some of the tables have more than 50,000. Recenlty the manager.merge() operation on most of the entities take more than 10 secs mainly due to the number of entities that get loaded and flushed back to database when merge() is called. This is strange behaviour as even when only one entity gets modified, all the entities in the memory gets flushed.
One of the solution i came up with was to use manager.clear() before calling manager.merge() to detach all entities. This seems to be working fine. I like to know:
1. Is this good programming practice?
2. Is this thread safe? One thread might be in different state with dirty enities about to persist or merge when other thread calls manager.clear() detaching all entities. Not sure what might happen?