We (b8e5n and I) have been fighting for too long for this, so there it is dear lazy web.

Using the eclipse JPA (Java Persistence API) to connect to a MySQL database you might experienced some troubles.

Using the following piece of code:

transaction = manager.getTransaction();
try {
     // Add here your logic
} finally {
     if (transaction.isActive()) {

We kept running into the fact that the rollback never happened. The commit was performed or at least started and if something was going wrong at the database level (like an already existing primary key), the data already commited to the database would remain in there.

So yay for the half-commited data :-s

It took us a while but we finally ended up finding the solution on a lost corner of the web:

** Please take special note for MySQL database users: do make sure that your tables are InnoDB tables instead of MyISAM. If not, rollback will not occur.

Switching from MyISAM to InnoDB solved the problem for us, the transaction is either fully commited or not at all.

Hope this can help.