Cryptic MySQL Errors
When you update a table, you must make sure to update any triggers on that table. If you don't, then the error message you get is often extremely cryptic.
One of the messages in the exception will probably be something like this:
SQLGrammarException: Could not synchronize database state with session
Depending on the problem, you will then get a more "detailed" message, which won't be all that useful. The one I saw was this:
Unknown column 'country' in 'field list'
This tends to be pretty confusing. If the field name changed or if the field was removed from your table (and you weren't aware of that), you won't be able to find that string anywhere -- not in your SQL, not in your data mapping layer, and not in the database itself. Very frustrating!
To find the problem in this case, I turned on MySQL protocol tracing (see Enable protocol tracing) and ran the actual select in SQLyog, where I saw the exact same error.
The protocol trace isn't the best way to get the select, because it's hard to cut-and-paste out of. If you really have no idea what select is being run, you are probably better off stepping through the code and grabbing the contents of the prepared statement (which is what's sent to MySQL in the protocol trace, anyway).
In any case, once you've reproduced the problem directly from an SQL prompt, you're half-way to solving it. (At least, you'll know that the problem lies with the database and not with your code.)