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

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 heard people say that fields are slower because they're called "through reflection" but then again so are the getter methods, no? Hibernate needs to set the accessibility of the field to true before it tries to read it which I can see having some slight overhead. However wouldn't that be done at the Class-level in the scope of a Session or perhaps only once when the Configuration is read and SessionFactory is built?

Just curious if this is a myth or if there's really truth to it; I personally find annotating the fields to be a bit more readable.


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.

Need Your Help

JQueryUI Dialog IE9 not opening jquery-ui dialog internet-explorer-9

I have an aspx page that contains a dialog box defined with JQueryUI

Spring with hibernate dont flush the session after exception error

spring hibernate flush

I am using Spring transaction management with Hibernate. My service layer methods are transactional. This error is occurring when am testing a use case when user is trying to create a company with an