Performance difference between annotating fields or getter methods in Hibernate / JPA

前端 未结 3 1715
太阳男子
太阳男子 2020-12-16 04:09

I was curious if anyone had any hard numbers around the performance difference between annotating Entities using private fields instead of public getter methods. I\'ve hear

3条回答
  •  清酒与你
    2020-12-16 05:05

    Loaded 5000 records into a simple 3 column table. Mapped two classes to that table, one using annotated private fields and another using annotated public getters. Ran 30 runs of Spring's HibernateTemplate.loadAll() followed by a HibernateTemplate.clear() to purge the Session cache. Results in ms below...

    methods total: 6510, average: 217

    fields total: 6586, average: 219

    I should probably take another stab at it after adding more properties to each class but right now the difference doesn't appear to be statistically significant.

提交回复
热议问题