I think joining on same table twice is possible with Hibernate. In fact, in my case I have similar domain model like yours wherein, I have Place and Tags objects (and tables) mapped as many-to-many bidirectional with places_tag as association table.
To retrieve Place object that is associated with both TagA and TagB, I have used the following HQL that does an inner join on the same table twice and able to get the right Place object.
Code:
Place place = (Place) session.createQuery("select p from Place p inner join p.tags t1 inner join p.tags t2 where t1.name=:tag1 and t2.name=:tag2").setString("tag1", tag1).setString("tag2", tag2).uniqueResult();
and this HQL resulted in following SQL.
Code:
Query:["select place0_.id as id1_2_, place0_.name as name2_2_ from place place0_ inner join tag_place tags1_ on place0_.id=tags1_.places_id inner join tag tag2_ on tags1_.tags_id=tag2_.id inner join tag_place tags3_ on place0_.id=tags3_.places_id inner join tag tag4_ on tags3_.tags_id=tag4_.id where tag2_.name=? and tag4_.name=?"]
With your domain model, assuming Tag class is mapped as List<Tag> as below,
Code:
@ManyToMany List<Tag> tags = new ArrayList<>();
the HQL would translate to
Code:
query = "select c FROM Case AS c INNER JOIN c.tags AS t1 INNER JOIN c.tags t2 WHERE t1.tagName = 'TagA' AND t2.tagName = 'TagB'"
This does does an inner join twice on c.tags. or Did I misinterpret your question?