문제

I have 2 entity classes Product and ProductAltID with no @OnetoMany mapping defined between them.

I want to do something like this

select p from ProductAltid inner join Product pai
where p.id = pai.id

How can I achieve this?

도움이 되었습니까?

해결책

Add this method to the ProductAltId repository (choosing that one because the query returns ProductAltIds):

@Query("select pai from ProductAltId as pai " 
+ "where pai.id in (select p.id from Product as p)")
List<ProductAltId> findForAllProducts();

I switched the aliases around, they seem backward in your example.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top