Pregunta

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?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top