← Back to team overview

dhis2-devs-core team mailing list archive

setAutoFields() anti-pattern

 

Hi guys

After some extensive cpu profiling today I have discovered that we are
using way too much time doing setAutoFields(), a few releases ago we
started doing a anti-pattern where we were setting auto fields in the
default constructor, which means that they are run by hibernate on every
single object creation, since 2.19 (2.18?) setting the fields is taken care
of by HibernateGenericStore on save/update and we should no longer be doing
this manually.

I have removed all usage of this in the default constructors, and updated
the affected tests. If you are doing testing and -not- saving your object,
you might either want to use one of the pre-defined creators
(createDataElement, createProgram etc) or simply do o.setAutoFields()
yourself.

--
Morten