I have developed a fairly large CRUD application, using a MYSQL Database and Swing Application framework and javax.persistence. My question is how should I best manage my transactions given the javax.persistence.Entitymanager? Currently, I have one instance of Entity manager held by the Application class. It is passed to all requesting pages, which in turn use it to persist and merge entities. I start a transaction on application start-up, and commit (and restart) each time a change is made. Is this correct? or should I hold a seperate Entity Manager for each Component / page? When should I commit? All these questions arised now, because I have recently started to get exceptions of the type: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction Error Code: 1205 which led me to believe I am doing something wrong in my management of database transactions....
Thanks in advance for any help you can give me!