Steve Chambers Steve Chambers - 1 year ago 68
MySQL Question

How to inspect data within a database transaction?

I'm running an integration test that executes some Hibernate code within a single transaction (managed by Spring). The test is failing with a duplicate key violation and I'd like to hit a breakpoint just before this and inspect the table contents. I can't just go into MySQL Workbench and run a

query as it would be outside the transaction. Is there another way?

Answer Source

The following can be run from Eclipse's "Display" view:

  em.createNativeQuery("SELECT mystuff FROM mytable").getResultList().toArray())
  .replace("], ", "]\n");

This displays all the data, albeit not in a very user-friendly way - e.g. will need to work out which columns the comma-separated fields correspond to.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download