General case: first table represents one-side, second table represents many-side. Third table serves as a link between the two.
My case: first and second tables are the same. Third table serves as a link between all pairs of tables which have one-to-many relationship. This third table has additional field (String) which contains information about 2 tables.
Little example. Suppose we have tables Project and Category (one category --> many projects). To obtain all projects with categories we need to perform next query:
select project.name, category.name
from nodeassociation, project, category
where nodeassociation.association_name='ProjectCategory'
and nodeassociation.source_id=project.id
and nodeassociation.sink_id=category.id
How can I specify association_name criterion by means of JPA?
UPD: if it's impossible with JPA but hibernate handles it then it's ok, what's the hibernate solution?