cleanup
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / hibernate / TaxonGraphHibernateListener.java
index 52fc902a0bec96aac5751b61de27f8e43272c084..1be88c30206c3c8fe974bf1f63100867a41f5562 100644 (file)
@@ -13,7 +13,8 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
 import org.hibernate.event.spi.PostInsertEvent;
 import org.hibernate.event.spi.PostUpdateEvent;
@@ -36,10 +37,11 @@ import eu.etaxonomy.cdm.model.name.TaxonName;
  *
  * @author a.kohlbecker
  * @since Sep 27, 2018
- *
  */
 public class TaxonGraphHibernateListener implements ITaxonGraphHibernateListener {
 
+    private static final Logger logger = LogManager.getLogger(TaxonGraphHibernateListener.class);
+
     private static final long serialVersionUID = 5062518307839173935L;
 
     private Map<Class<? extends BeforeTransactionCompletionProcess>, ProcessConstructorData<? extends BeforeTransactionCompletionProcess>> beforeTransactionCompletionProcessTypes = new HashMap<>();
@@ -68,7 +70,7 @@ public class TaxonGraphHibernateListener implements ITaxonGraphHibernateListener
                     event.getSession().getActionQueue().registerProcess(processorInstance);
                 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
                         | InvocationTargetException | SecurityException e) {
-                    Logger.getLogger(TaxonGraphHibernateListener.class).error("Error creating new instance of " + type.toString(), e);
+                    logger.error("Error creating new instance of " + type.toString(), e);
                 }
             }
         }
@@ -85,7 +87,7 @@ public class TaxonGraphHibernateListener implements ITaxonGraphHibernateListener
                     event.getSession().getActionQueue().registerProcess(processorInstance);
                 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
                         | InvocationTargetException | SecurityException e) {
-                    Logger.getLogger(TaxonGraphHibernateListener.class).error("Error creating new instance of " + type.toString(), e);
+                    logger.error("Error creating new instance of " + type.toString(), e);
                 }
             }
         }
@@ -102,7 +104,7 @@ public class TaxonGraphHibernateListener implements ITaxonGraphHibernateListener
                     event.getSession().getActionQueue().registerProcess(processorInstance);
                 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
                         | InvocationTargetException | SecurityException e) {
-                    Logger.getLogger(TaxonGraphHibernateListener.class).error("Error creating new instance of " + type.toString(), e);
+                    logger.error("Error creating new instance of " + type.toString(), e);
                 }
             }
         }
@@ -136,6 +138,7 @@ public class TaxonGraphHibernateListener implements ITaxonGraphHibernateListener
                 postInsertEventConstructorArgTypes[i] = ptype;
                 postUpdateEventConstructorArgTypes[i] = ptype;
                 preDeleteEventConstructorArgTypes[i] = ptype;
+                i++;
             }
             postInsertEventConstructor = type.getConstructor(postInsertEventConstructorArgTypes);
             postUpdateEventConstructor = type.getConstructor(postUpdateEventConstructorArgTypes);