BaseORMService and Nested Transactions

Hello Guys,

I ran into a problem this week, when trying to implement this concept in my integration tests, which wraps each test in a transaction, and then rolls it back once complete, this preserves the test datas integrity and stops it getting polluted when running tests, and also makes your integration tests run much quicker.

The error I was getting was that when it was running rollback() on the teardown, it said the transaction had not been started. After some Googling around, this is a common message when the transaction has already been committed and closed.

It seems that this is due to a conflict of interest in the way that the BaseORMService, and therefore the VirtualEntityService works with transactions on save.

Has anyone got any suggestions on ways to get around this? I had always thought that transactions could be nested, is that not the case in this approach?


Coincidentally, I’ve also been thinking about Fixtures recently, think that would make a great addition to the framework.

As a developer, the ability to define test data in a flat file makes good sense. Then have it loaded into the database at the beginning of testing.

Has anyone put much thought into this?

The main issue with this is with using BaseORMService and the transactional around say save, by removing this code in the BaseORMService I actually had no problems from then on.


Andrew Scott

Thanks Andrew,

Yeah that's certainly the problem. The thing is, I don't want to implement infrastructure in my test cases that is going to break as soon as I try to add transactions into the application.

Not quite sure what approach to take. I almost need to apply the 'rollback every transaction' logic at a lower level than in the tests, and run the app in 'rest' mode. I'm not sure I like that though.