How does this SQL query translate to JPQL?
I´m trying to get accustomed to JPQL, but i´m already stuck. How does this:
SELECT * FROM Table_a INNER JOIN Table_b USING (Table_bID) Where Table_b.Column_a LIKE 'somestring'
translate to JPQL ? I would very much appreciate any he开发者_运维百科lp.
select a from EntityMappedToTableA
inner join fetch a.entityMappedToTableB b
where b.fieldMappedOnColumnA like :someString
For this to work, you must have a relationship (I assume it is a ManyToOne, since there seems to be several rows in table A which have the ID of table B) from EntityMappedToTableA to EntityMappedToTableB :
@Entity
public class EntityMappedToTableA {
@ManyToOne
@JoinColumn(name = "Table_bID")
private EntityMappedToTableB entityMappedToTableB;
// ...
}
精彩评论