use*_*775 4 hibernate jpa spring-data-jpa spring-boot
我有这样的方法
@Modifying( clearAutomatically = true )
@Query( "update versioned LookupMaster set state = 'PUBLISHED' , value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = 'MODIFIED')" )
void commitLookupTableChanges( String tableName );
Run Code Online (Sandbox Code Playgroud)
在 springboot 3 升级之前它可以工作。springboot 升级到版本 3.0.2 后面临如下验证错误。
Caused by: java.lang.IllegalArgumentException: org.hibernate.query.SemanticException: The assignment expression type [java.lang.String] did not match the assignment path type [com.nokia.nsw.lookuptable.model.RowState] for the path [alias_2093546827.state] [update versioned LookupMaster set state = 'PUBLISHED' , value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = 'MODIFIED')]
Run Code Online (Sandbox Code Playgroud)
行状态代码:
public enum RowState {
MODIFIED, DELETED, PUBLISHED
}
Run Code Online (Sandbox Code Playgroud)
PUBLISHED删除和周围的单引号MODIFIED。即,将查询更改为:
update versioned LookupMaster set state = PUBLISHED, value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = MODIFIED)
Run Code Online (Sandbox Code Playgroud)
所以这是一个错误https://hibernate.atlassian.net/browse/HHH-16170我们将修复它。
作为临时解决方法,您可以使用枚举值的完全限定名称来编写查询:
update versioned LookupMaster set state = full.package.name.RowState.PUBLISHED, value = newValue, newValue = null, updatedDate = current_timestamp where ( name = :tableName and state = MODIFIED)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1071 次 |
| 最近记录: |