File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Swing issues Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Swing issues" Watch "Swing issues" New topic
Author

Swing issues

jay vas
Ranch Hand

Joined: Aug 30, 2005
Posts: 407
I have read quite alot about hibernate causing problems with swing, mainly due to the swing event model and threading.

Can someone explain this to me in "laymans" terms ? Im an advanced java developer, but I don't understand why or how it could be that hibernate make multiple sessions because of the Swing architecture.

In particular, I wonder - why would hibernate even have access or knowledge of swings architecture or threading to begin with.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32765
I haven't seen those discussions (but would be interested if you could point to them). I would imagine that they go back to the fact that in Swing, processing that takes more than a short time to finish should not be done in the GUI thread (which is the one that runs GUI listeners). So for DB access (presumably a not-so-short process) you should start its own thread with its own Session.

Since control returns to the GUI after the worker thread starts, that means that a user could start another thread doing DB stuff before the first one finishes, thus potentially leading to concurrency problems. Not a problem for read-only operations, but something to think about for transactions.

One way around this is would be to disable parts of the GUI that could cause problems while a transaction is running, or to run transactions from the main GUI thread (which means that the complete becomes unresponsive to any user actions).


Android appsImageJ pluginsJava web charts
 
 
subject: Swing issues
 
Threads others viewed
Detail for the content of the programmer exam
Why EJB
guide me for scjd
Hibernate + Multi User Swing App + JBoss
Update GUI components from another thread.
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture