我有实体用户和报告
class User {
@JoinColumn(name = "user_id")
protected Set<BattleReport> reports;
}
class Report {
byte data;
}
我知道用户 ID,我需要在不加载用户的情况下更新用户的报告数据。怎么做?
我已经尝试过这种方式,但它不起作用:
Query reportsQuery = session.createQuery("SELECT reports FROM User WHERE id = :id");
reportsQuery.setParameter("id", id);
List<?> list = reportsQuery.list();
for (Object o : list) {
Report report = (Report) o;
report.setData(42);
session.update(report);
}