开发者

Problem using AbstractTransactionalJUnit4SpringContextTests

开发者 https://www.devze.com 2023-03-30 22:16 出处:网络
I am using AbstractTransactionalJUnit4SpringContextTests to test my dao implementations. The above abstract class has a method exeuteSqlScript which i am trying to execute before each test case.

I am using AbstractTransactionalJUnit4SpringContextTests to test my dao implementations. The above abstract class has a method exeuteSqlScript which i am trying to execute before each test case.

So my problem is when i am trying to execute the testcase for saving a record开发者_如何学运维 it gives me the below exception org.springframework.dao.CannotAcquireLockException: Hibernate operation: could not insert.

Also i dont see any records inserted in the database with the executeSqlScript from the implementation calss of AbstractTransactionalJUnit4SpringContextTests. from the sql script trying to insert few records.

P.S. i am using spring2.5 and hibernate 3 and mysql.

Thanks for any help


You need to add a transaction manager to your test configuration.

You still may have trouble observing INSERT record changes unless you tell Hibernate to flush the transaction.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号