Do you mean to say that below lines 4 & 5 are not required? The constructor of JmxServiceImpl.java does not register the MBean. I think we need to call some method to register the MBean. Otherwise how will it know what to register, beacause we are not passing the ObjectName in JmxServiceImpl constructor.
REQUIRED
1. HashMap<String, String> configMap = new HashMap<>();
2. configMap.put("hibernate.jmx.usePlatformServer" , "true");
3. JmxService jmxService = new JmxServiceImpl(configMap);
NOT REQUIRED
4. Statistics statistics = sessionFactory.getStatistics();
5. jmxService.registerMBean(new ObjectName("Hibernate:application=Statistics"),statistics);