Ok, I have some additional info. In one case, the correct ID that SHOULD have been there is id1 = 119773. The wrong id is id2 = 87005.
If I convert those to binary format, I get:
id1 = 11101001111011101 id2 = 10101001111011101
As you can see, the second bit (from the left) flipped.
I'm beginning to see where the problem may be... something with number conversion between formats?
My IDs in the Java classes are of type java.lang.Long, the corresponding fields in the DB (PK and FK columns, autogenerated) are of type BIGINT(20).
It's strange, but the behaviour I described above is not reproducable. I checked in the DB and found many rows where the correct value (119773) was written.
I identified six cases where this behaviour occured, and for all of them, there are other rows in the DB where the value was written correctly.
Strangely, of the six cases I identified, 3 respectively 2 occured with the same ID. Again, in other rows, those very same IDs were written correctly.
In all cases, the bit #16 changed from 1 to 0.
Does anybody have an idea what could be the cause for this strange behaviour?
This problem went away after I updated to the newest MySQL JDBC version.