Pergunta

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?

Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top