Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Swing issues

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic