我正在使用JUnit进行测试.
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:com/mt/sm/application-context.xml","classpath:com/mt/sm/security-context.xml"})
@TransactionConfiguration(transactionManager = "transactionManager",defaultRollback = true)
@Transactional
public class LocationPathServiceImplTest { /* Class code here */ }
测试方法的声明非常简单:
@Test
public void testRefresh() { /* Method body */}
我已经创建了一个在setup()中保存obj的文件,然后保存到数据库.
在@Test中,我从DAO运行refresh()(refresh()方法仅调用EntityManager .refresh()),但这会导致以下错误
org.hibernate.HibernateException: this instance does not yet exist as a row in the database
javax.persistence.PersistenceException: org.hibernate.HibernateException: this instance does not yet exist as a row in the database
我不知道如何解决它.有人遇到过吗?
所有建议将不胜感激.
最佳答案
原文链接:https://www.f2er.com/spring/531766.html