出现org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient
2017-05-05 13:56
603 查看
出现的问题就是org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: com.vvv.entity.Order; nested exception is org.hibernate.TransientObjectException:
object references an unsaved transient instance - save the transient instance before flushing: com.vvv.entity.Order,当你保存一个更改的表时,首先保存这个表的外键所在的表。
就像我遇到的这个错误一样 ,想着只保存订单条目,而忘记保存订单表,就会出现这个错误。所以要多注意外键做造成的错误。
orderService.add(order); orderItemService.add(orderItem);
相关文章推荐
- org.springframework.dao.InvalidDataAccessApiUsageException:object references an unsaved transient in
- org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifi的解决方案
- org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist: sys.entity.Role; nested exception is org.hibernate.PersistentObjectException: 的解决方案
- org.springframework.dao.InvalidDataAccessApiUsageException: ERR value is not an integer or out of ra
- org.springframework.dao.InvalidDataAccessApiUsageException: The given object has a null identifier:
- org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifi的解决方案
- org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifi的解决方案
- id为空的org.springframework.dao.InvalidDataAccessApiUsageException: The given object has a null identifier
- org.springframework.dao.InvalidDataAccessApiUsageException:The given object has a null identifi的解决方案
- An exception occurred: org.springframework.dao.InvalidDataAccessApiUsageException
- org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exc
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read
- [spring]:org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode
- org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER)
- OpenSessionInViewFilter与org.springframework.dao.InvalidDataAccessApiUsageException
- org.springframework.dao.InvalidDataAccessApiUsageException
- org.springframework.dao.InvalidDataAccessApiUsageException
- org.springframework.dao.InvalidDataAccessApiUsageException
- javaEE-----org.springframework.dao.InvalidDataAccessApiUsageException: Write operation