我们可以使用@NamedNativeQuery 创建更新语句吗?
@Entity
@Table(schema = "public", name = "conversion_checker")
@NamedNativeQueries({
@NamedNativeQuery(name="updateExpireStatus", query="UPDATE conversion_checker SET status='Expired' FROM conversion_checker ")
})
public class ConversionChecker extends BaseEntity {...}
在这里我正在执行本机查询
/**
* {@inheritDoc}}
*/
@Override
public int executeNativeUpdate(String namedNativeQuery, Map<String, Object> params) {
Query query = getSession().getNamedQuery(namedNativeQuery);
if(params!=null && params.size()>0){
for(Map.Entry<String, Object> param: params.entrySet()){
query.setParameter(param.getKey(), param.getValue());
}
}
return query.executeUpdate();
}
它抛出,
Caused by: org.hibernate.cfg.NotYetImplementedException: Pure native scalar queries are not yet supported,
如何使用 @NamedNativeQuery 执行更新语句,否则这是不可能的?