properly managing and integrating the the spring transactions is not a trivial task. i managed to track down where the problem is. it seems we overlooked a lot of things before :-)
problem is located when a query is done in spring. normally hibernate should do a flush first automatically. but in the spring configuration hibernate doesn't do auto flushing before executing queries.
spring is managing the transactions. so we should not be calling session.beginTransaction in the hibernate api. now for some reason, the default jdbc transactionfactory that is configured thinks that there is no transaction when a query is done. so the auto flushing on query is skipped.
this seems like a trivial case. yet i didn't find a clue on how we're suppose to make this work. could it be a bug ?
eventually i found out in the spring 3 codebase that there is a SpringTransactionFactory. I was hopeful about cause hibernate's check to see if the transaction is active was delegated to the transaction factory (originally the JDBC transaction factory).
so i took that source code and put it in our codebase and configured it. and it still didn't work. still the spring transaction factory says that the transaction is not in progress.
yet when i hard code "return true;" in the method isTransactionInProgress, then the test succeeds.
--Amai mn botten.--