I have an object Favourite. This object has a many to many connection with Colors. Lets say that some favourites have many colors, 2-3 etc. When I search for a favourite like:
SELECT fav FROM Favourite fav join fetch fav.colors as cl WHERE fav.name = "blabla" .
The resulting object contains all the colors related to this favourite. My problem is when I want to search for a favourite that has a certain color. For example:
SELECT fav FROM Favourite fav join fetch fav.colors as cl WHERE cl.name = "red"
Then the resulting object contains only the red color. I want to get as a result the fav objects that contain the “red” color, but also show all the related colors. Any suggestions? Thanks in advance.
Well finally it worked with an inner query and “EXISTS” operator. (color is an object of , int id and string name).