Fix session problems #5592
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 29 Mar 2016 12:20:55 +0000 (14:20 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 29 Mar 2016 12:20:55 +0000 (14:20 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java

index 8340b243f3316ddd7316e10baa53b7f72cfb0c8f..adcbfeccd6afe4583ec11dd29ceb3a88432d5f04 100644 (file)
@@ -87,11 +87,12 @@ public class EditFromSelectionWizard extends Wizard implements
        public void addPages() {
 
                CdmFormFactory formFactory = selectionElement.getFormFactory();
-               CdmBase entity = (CdmBase) HibernateProxyHelper
+               CdmBase entity = HibernateProxyHelper
                                .deproxy(selectionElement.getEntity());
                //check if entity has already been persisted
                if(entity.getId()==0){
                        rootElement = entity;
+                       cdmEntitySession.addNewCdmEntity(rootElement);
                }
                else{
                        IService<CdmBase> service = CdmStore.getService(entity);
@@ -172,9 +173,11 @@ public class EditFromSelectionWizard extends Wizard implements
        @Override
        public boolean performFinish() {
            IService<CdmBase> service = CdmStore.getService(rootElement);
-           service.merge(rootElement, true);
+           if(rootElement.getId()!=0){
+               service.merge(rootElement, true);
+           }
            if(previousCdmEntitySession!=null){
-               previousCdmEntitySession.load(rootElement, true);
+               selectionElement.setEntity(previousCdmEntitySession.load(rootElement, true));
            }
                return true;
        }
@@ -201,7 +204,7 @@ public class EditFromSelectionWizard extends Wizard implements
             cdmEntitySession.dispose();
         }
         if(previousCdmEntitySession!=null){
-            previousCdmEntitySession.bind();
+            previousCdmEntitySession.dispose();
         }
     }