[jboss-user] [EJB/JBoss] - Use of EntityManager.clear()

murtuza52 do-not-reply at jboss.com
Tue Dec 19 11:26:07 EST 2006


Current setup:
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?

Thanks
Murtuza

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995061#3995061

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995061



More information about the jboss-user mailing list