knowing/Medmon — comment on commit 47862115edacb6dcc782c7de180b534999303541
File:  line 0
By muuki88:

### SelectionAdapter classes

Separating UI and Logic is normally a good thing. However creating a bunch of SelectionAdapter classes
makes it hard to figure out what the button does. Furthermore 50% of the code in the SelectionAdapter
classes could be avoided if they were anonymous classes inside the corresponding view, e.g in SADeleteTherapy.class
this code is doubled

```java
GlobalSelectionProvider selectionProvider = new GlobalSelectionProvider(Activator.getBundleContext());
Therapy selectedTherapy = selectionProvider.getSelection(Therapy.class);
if (selectedTherapy == null) {
return;
}

....
selectionProvider.updateSelection(Patient.class);
selectionProvider.setSelection(Therapy.class, null);
selectionProvider.unregister();
```

### Whiteboard pattern the wrong way around

The EntityManagerProvider does actually nothing, because no service makes use of it.
It's just to hook into the OSGi-ServiceRegistry. In this case ServiceTracker or DependecyInjection
(which is unfortunately too time expensive to test it in the current project).
As a consequence this change has to be dismissed. See more here:
[StackOverflow - OSGi best practice](http://stackoverflow.com/questions/7919409/osgi-services-best-practice)

### One EntityManager to rule them all

There are a few points here, which make this a not very scaling approach

* All merged entites remain in the persistence context, which means they can't be gc
* EntityManger is thread-safe, so this only works if the EntityManager is used in the UI thread only

There two patterns (session-per-request / session-per-workunit) describe [here](http://docs.jboss.org/hibernate/core/3.3/reference/en/html/transactions.html)
Hibernate use "Session" which is similiar to an EntityManager

Also look [StackOverflow discussion](http://stackoverflow.com/questions/2586606/java-jpa-when-we-need-more-than-one-entitymanager)
and [JavaNotepad Blog](http://javanotepad.blogspot.com/2007/08/managing-jpa-entitymanager-lifecycle.html)

The IEntityManagerService currently got a method "getEntityManager", which returns a singleton
EntityManager. This EntityManager should never be closed. A better approach would be to see
a "unit of work" as a "Tab" or "View" which does a "unit of work".