Replacement or workaround for org.hibernate.jmx.statisticsservice in hibernate 5.2.1

As a work around they suggest to use your own spring bean. From Hibernate JIRA HHH-6190

public class HibernateStatisticsFactoryBean implements FactoryBean<Statistics> {

  @Autowired
  private EntityManagerFactory entityManagerFactory;

  @Override
  public Statistics getObject() throws Exception {
    SessionFactory sessionFactory = ((HibernateEntityManagerFactory) entityManagerFactory).getSessionFactory();
    return sessionFactory.getStatistics();
  }

  @Override
  public Class<?> getObjectType() {
    return Statistics.class;
  }

  @Override
  public boolean isSingleton() {
    return true;
  }
}

Then you can export this as MBean: From Spring Doc