# Custom Statistics

**URL:** <https://discourse.hibernate.org/t/custom-statistics/2670>\
**Category:** Hibernate ORM\
**Created:** [May 7, 2019, 6:36pm UTC](https://discourse.hibernate.org/t/custom-statistics/2670 "2019-05-07T18:36:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpd](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@tpd](https://discourse.hibernate.org/u/tpd)\
**Post date:** [May 7, 2019, 6:36pm UTC](https://discourse.hibernate.org/t/custom-statistics/2670/1 "2019-05-07T18:36:04Z")

</div>

Hibernate includes:

- a Statistics interface (org.hibernate.stat.Statistics) and
- a StatisticImplementor interface (org.hibernate.stat.spi.StatisticsImplementor) that extends the first interface, and
- a StatisticImpl class (org.hibernate.stat.internal.StatisticsImpl) that implements StatisticsImplementor

If I want to use a custom implementation of the interface StatisticsImplementor, how can I get Hibernate to use instances of that class?

Is there some Factory I override to produce my customized StatisticImpl? Or some configuration field where I giveits fully qualified class name?

My goal is for Hibernate to use my custom class anywhere it would currently use the out-of-the-box StatisticImpl.

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![Naros](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/naros/32/19_2.png) [@Naros](https://discourse.hibernate.org/u/Naros)\
**Post date:** [May 8, 2019, 8:44pm UTC](https://discourse.hibernate.org/t/custom-statistics/2670/2 "2019-05-08T20:44:34Z")

</div>

You want to actually provide Hibernate an instance that implements the the `StatisticsFactory` in the configuration under the key `hibernate.stats.factory`. By doing that, Hibernate will use your custom factory to create the statistics object rather than the default behavior of instantiating a `StatisticsImpl`.
