Summary:
- Starting with MySQL 5.6, when you save a value with millisecond precision (like a java.util.Date) into a database field with second precision (like OpenMRS date fields), the value is rounded. (Through MySQL 5.5 it was truncated.)
- e.g. in MySQL 5.5 if I save “2015-06-04 12:34:56.789” => it saves as “2015-06-04 12:34:56”
- but in MySQL 5.6 if I save “2015-06-04 12:34:56.789” => it saves as “2015-06-04 12:34:57”
- people have complained about this, but no response from MySQL developers (see bug below)
- This means that 50% of the time if you try to save a real-time visit or encounter, it will fail OpenMRS validation because it is “in the future”
More details:
- http://bugs.mysql.com/bug.php?id=68760
- https://groups.google.com/a/openmrs.org/d/msg/dev-archive/JGBG4FXxOc4/nHk_o_8NLUsJ
- https://issues.openmrs.org/browse/TRUNK-4252
The identical fix (adding a DropMillisecondsHibernateInterceptor) has been applied in Mirebalais, Bahmni, Ebola and has been working fine in production for years. And basically you can’t run OpenMRS on MySQL 5.6+ for point-of-care purposes without this fix.
I will add this to openmrs-core shortly, unless anyone objects.
(In fact I asked of anyone had thoughts/objects a year ago, so I think it’s well past time to actually apply this fix. Though I’m surprised that nobody else has ever complained about this. The driver for me noticing this now is that if you try to run Bahmni + Mirebalais together, things fail, because of the incompatible bean definitions.)