Hello.
Is this possible to use a <subselect> instead of a real table or view to make a many-to-many association ?
I have to map a many-to-many association between two tables, but there is no join table. This association is based on a tricky interval system.
The database schema is actually something like 15 years old and cannot be changed. And the database stores too much data to add views in it now.
Below is a simplified view of the join request.
Is there a way to use it as a real join table in a many-to-many association, or a way to use this subselect directly in the many-to-many declaration itself.
A bidirectionnal association isn't absolutly mandatory if it can helps.
Code:
<class name="JoinAB">
<subselect>
select distinct
a.idA1, a.idA2,
b.idB1, b.idB2, b.idA1_start, b.idA1_end
from
A as a, A as aStart, A as aEnd, B as b
where
aStart.idA1 = b.idA1_start
and aEnd.idA1 = b.idA1_end
and aStart.idA2 <= a.idA2
and a.idA2 < aEnd.idA2
</subselect>
<synchronize table="A"/>
<synchronize table="B"/>
<composite-id>
<key-property name="idA1"/>
<key-property name="idA2"/>
<key-property name="idB1"/>
...
</composite-id>
</class>
PS : For the hibernate Team. Resolving this problem can help me to make a worldwide industry leader to look closer at Hibernate. What ?? Look i so desparate !!! ... I am !! ;)