【发布时间】:2021-11-24 20:46:19
【问题描述】:
StringBuffer buffer = new StringBuffer();
buffer.setLength(0);
buffer.append("select phone.name,phone.id,object.name,object.id from Phone as phone");
if(isA){
buffer.append("left outer join A as object where object.id=phone.id")
}
else{
buffer.append("left outer join B as object where object.id=phone.id")
}
我在旧代码中有这样的 SQL 命令。我必须将其转换为 JPA。
如果Phone与A和B之间没有任何关系,如何使用条件查询来实现?
【问题讨论】:
标签: hibernate jpa hibernate-criteria criteria-api criteriaquery