我试图习惯JPQL,但是我已经陷入困境。怎么做的:SELECT * FROM Table_a INNER JOIN Table_b USING (Table_bID) Where Table_b.Column_a LIKE 'somestring'
翻译成JPQL吗?非常感谢您的帮助。
最佳答案
select a from EntityMappedToTableA
inner join fetch a.entityMappedToTableB b
where b.fieldMappedOnColumnA like :someString
为此,您必须具有从EntityMappedToTableA到EntityMappedToTableB的关系(我假设它是ManyToOne,因为表A中似乎有几行具有表B的ID):
@Entity
public class EntityMappedToTableA {
@ManyToOne
@JoinColumn(name = "Table_bID")
private EntityMappedToTableB entityMappedToTableB;
// ...
}
关于mysql - 该SQL查询如何转换为JPQL?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5143035/