标签:spring exce 引用 nbsp 原因 测试 highlight lis emd
在测试多对多关联时报错:如果不是本文这个原因,请另寻他路。
ItemCategory category = new ItemCategory(2l,"cat1","1",1l,new Date(),null,null);
ItemCategory category2 = new ItemCategory(1l,"cat1","1",1l,new Date(),null,null);
List<ItemCategory> categories = new ArrayList<>();
categories.add(category);
categories.add(category2);
// itemCategoryDao.save(category);
// itemCategoryDao.save(category2);
Item item = new Item("item1",1l,"item1path","itemdesc1",111l,1l,new Date(),null,categories);
itemDao.save(item);
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.ruixun.yupoo.bean.ItemCategory; nested exception is java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: org.ruixun.yupoo.bean.ItemCategory
错误的翻译应该是:瞬时态对象异常(TransientObjectException),对象引用了一个没有报错的瞬时态实例(object references an unsaved transient instance)
系统让你在保存item之前,先保存itemCategory。加上我的那个注释的就行了
标签:spring exce 引用 nbsp 原因 测试 highlight lis emd
原文地址:https://www.cnblogs.com/5aixin/p/11839106.html