java - 在 Hibernate 中加入的预期路径
问题描述
我有 2 张桌子:
在我的 GnrlOrgChargeCode.java 文件中,我有:
private Set<IOrgChargeCodeCond> orgChargeCodeConds;
@OneToMany(mappedBy = "gnrlOrgChargeCode", targetEntity = OrgChargeCodeCond.class,
fetch = FetchType.LAZY)
public Set<IOrgChargeCodeCond> getOrgChargeCodeConds() {
return orgChargeCodeConds;
}
public void setOrgChargeCodeConds(Set<IOrgChargeCodeCond> orgChargeCodeConds) {
this.orgChargeCodeConds = orgChargeCodeConds;
}
在我的 OrgChargeCodeCond 文件中:
private IGnrlOrgChargeCode gnrlOrgChargeCode;
@ManyToOne(targetEntity = GnrlOrgChargeCode.class,
fetch = FetchType.LAZY)
@JoinColumn(name = "ORG_CHARGE_CODE_ID", insertable=false, updatable=false)
public IGnrlOrgChargeCode getGnrlOrgChargeCode() {
return gnrlOrgChargeCode;
}
public void setGnrlOrgChargeCode(IGnrlOrgChargeCode gnrlOrgChargeCode) {
this.gnrlOrgChargeCode = gnrlOrgChargeCode;
}
我的休眠查询是:
from GnrlOrgChargeCode gocc left join OrgChargeCodeCond occc where gocc.orgId = ?
但我收到一个错误:
预计加入的路径!
请帮忙。谢谢。
解决方案
你需要一个像from GnrlOrgChargeCode gocc left fetch join gocc.orgChargeCodeConds occc where gocc.orgId = ?
. 除此之外,从 5.1 版开始支持实体连接。由于您收到此错误,因此您似乎使用的是旧版本。我建议您尽快更新,因为您很可能不会收到对旧版本的任何实质性支持/帮助。
推荐阅读
- vue.js - Vue Test Utils:即使对道具的测试通过,也缺少必需的道具
- php - 允许所有普通用户显示和阅读 laravel 中的所有帖子
- python - AttributeError:'list'对象没有属性'split' - Python
- spring - 使用 JdbcStore 时配置 JWT 令牌过期时间
- javascript - 我怎样才能分别做过渡动画?
- c++ - 为什么链接器在链接共享和静态时不会抱怨多个定义
- android - 在 BottomNavigation 的片段中查看 pager2
- mongodb - 未处理的承诺拒绝警告和服务器连接错误
- sql - 如何在 Sequel Pro 中从具有重复字段的 .CSV 文件创建新表
- python-3.x - 尝试加载 Python 模块时出现 ModuleNotFoundError 并且一切正常