Hi everyone,
I'm encountering a little problem with annotations. I was able to have ManyToMany collections with a generated query using the where attribute on the set tag (with xml definitions)
Code:
<class table="TABLEA" ....>
<set name="affaires" table="LINKS" inverse="true" where="LINK_TYPE='EVT' and FROM_TYPE='EVT' and TO_TYPE='AFF'">
<key column="FROM_ID" />
<many-to-many column="TO_ID" class="com.itnsa.gestion.bean.FAffaires"/>
</set>
...
</class>
which generated the corresponding join query clause
Code:
... WHERE TABLEA.ID = LINKS.FROM_ID
AND LINKS.LINK_TYPE='EVT'
and LINKS.FROM_TYPE='EVT'
and LINKS.TO_TYPE='AFF'
AND TABLEB.ID = LINKS.TO_ID ...
Now using annotations, one of the closest try i used is something like this
Code:
@ManyToMany(
fetch = FetchType.LAZY
)
@JoinTable(
name="LINKS",
joinColumns= {@JoinColumn(name="FROM_ID")},
inverseJoinColumns= {@JoinColumn(name="TO_ID")}
)
@Where(clause="LIP_TYPE_LIEN='EVT' and LIP_TYPE_PIECE_1='EVT' and LIP_TYPE_PIECE_2='AFF'")
which generated :
Code:
... TABLEA.ID = LINKS.FROM_ID
AND TABLEB.LINK_TYPE='EVT'
and TABLEB.FROM_TYPE='EVT'
and TABLEB.TO_TYPE='AFF'
AND TABLEB.ID = LINKS.TO_ID ...
the @Where is working as intended, but it's not what i was looking for.
I've searched through the documentation, the forum, googled it but i couldn't found any clue on how to do this.
Is there a corresponding attribute or annotation to the where attribute of the set tag ? Is it even possible with annotations ?
Thanks,
Sebastien.