When this sort of thing happens to me, it's usually because my validation process performs a query on the A object. This is a very common situation: if you want to validate A, you often need to know about other things in the database that refer to A. The problem is that when hibernate notices that you're querying relative to A, and A is dirty in the session, it'll flush A back to the DB so that the query works with the most up-to-date data.
The way to handle this is to start your save transaction before starting your validation. That way, when validation fails, you can rollback and undo the auto-flushed changes.
_________________ Code tags are your friend. Know them and use them.
|