当保存字段标记为updatable=false的实体时,禁用警告 "实体已被修改,但不会更新,因为属性是不可改变的"。

问题描述 投票:0回答:1

我有一些字段标记为@Column(name = "column1", updatable = false)的实体在jpa资源库中,它的工作原理,但当保存实体时,会显示这样的警告信息。

2020-04-23 18:48:34.358  WARN 1112 --- [nio-8080-exec-6] o.h.p.entity.AbstractEntityPersister     : HHH000502: The [column1] property of the [com.nodobanka.core.data.model.Entity1] entity was modified, but it won't be updated because the property is immutable.

我只想知道如何才能阻止这个警告打印在日志中?

java spring hibernate jpa logging
1个回答
0
投票

你可以设置日志级别 org.hibernate.persister.entity 包给 ERROR. 这样,它就会只显示带有以下内容的日志 ERRORFATAL 级别。

你可以在 在application.properties文件中添加以下一行,就可以实现Spring的功能。:

logging.level.org.hibernate.persister.entity: ERROR
© www.soinside.com 2019 - 2024. All rights reserved.