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.

Answers


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

Prolog removing all variables and duplicates

list prolog

I need a query, which will remove me all variables and duplicates from list.

Local or streamed audio using JavaScript with CefSharp or CefGlue

c# javascript html5 audio chromium

I've been toying with CefSharp and CefGlue and managed to get CefSharp to work quite well in a C# application.

JQuery - Access ID of IMG appended to table for php script

jquery dom append appendto

Basically, I've got a table displays a few rows with a delete button next to them. When someone clicks on the delete button, I take the ID of that button, pass it to a php script, delete the record...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.