@DynamicUpdate和@DynamicInsert使用方法的场景类似,下面以@DynamicInsert为例,并结合我的实例进行解释;
数据、环境如下:
- product_info表:update_time在行数据更新时修改为当前时间
- 数据访问使用 JPA
现在需要在单元测试中插入一条数据,那么update_time会修改为当前时间,但是实际上,测试会报空指针异常。代码如下:
//测试方法
@Autowired
ProductInfoRepository repositroy;
@Test
@Test
void save() {
ProductInfo productInfo