Announcement Announcement Module
No announcement yet.
Spring + Hibernate + Swing Remote Client Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring + Hibernate + Swing Remote Client

    Hello all,

    I have a project that uses Hibernate in an Spring configuration with a Java Swing remote client.

    I have read that it is preferred that I should wrap my services in a transaction over my DAOs. Well if I do that then my service object is wrapped in a proxy to manage the transactions. So, how am I supposed to handle exceptions? Say if the user wants to update an object but is blocked as optimistic locking has given the lock to anther user. Should I then what? Wrap my proxy in an around advice to capture exceptions I want to forward to the client? Not sure what to do here, as I can't handle exceptions in the service object as the transaction happens outside all of its method calls it never sees an exception occur? Or should i create some silly intermediate object between my remote client calls and my service methods that only exists to catch exceptions I want referred back to the remote client? Should I use the HibernateTemplate or HibernateDaoSupport to translate the hibernate exceptions to Spring exceptions thereby at least only needing to look at Spring exceptions on the remote client.

    I have only come up with those methods of handling exceptions so far. I just feel like there must be some elegant Spring way to handle this that helps me avoid polluting my remote client with stuff like database error handling, hibernate exception handling, or lots of try/catch blocks when it shouldn't need to know these kinds of things. It should just have to know saving data to the server failed so do something appropriate like refresh the data object with new data, or display a diff screen showing the new data vs. their changes to the data, or just displaying an error dialog.

    Any help or advice would be greatly appreciated.