Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top