title: Java Desktop-App design - MVC with Hibernate
body: <p>I have a few design questions concerning my Java-Application. 
  The software is a desktop application that uses a MySQL database to store different kind of objects (customers, employees, documents). Each employee has a collection of customers and each customer contains a number of documents. The whole structure is lazy-loaded via hibernate. </p>
  
  <p>I currently use these four layers to build up my application</p>
  
  <ul>
  <li>model - objects containing the data e.g. customers, employees, ...</li>
  <li>views - a view for each action (adding a customer, creating a document, ...)</li>
  <li>controller - each view has its own controller, that controls one or more business objects</li>
  <li>business objects - encapsulate the logic for the actions on the models (adding a customer = customerBO, adding a document = documentBO, ...)</li>
  </ul>
  
  <p>So when the user now wants to add a new document to a customer, the controller of the customer-view opens a new - let's call it - "document-window" that has its own controller. 
  Since every document has to belong to a customer I pass the customer over as a parameter. But if I use this way I have to make sure that the current hibernate session is opened and the customer-object is reattached to the session to use lazy-loading. </p>
  
  <p>So my question now: Is there a more elegant way to do this? Maybe via a session-class that stores the currently active customer or so? Or is there a mistake in my structure in general that I didn't see?</p>