Hi!
In my database is 2 tables:
Keywords
----------
ID INTEGER
Keyword VARCHAR
and
Links
----------
Keyword1 INTEGER
Keyword2 INTEGER
So there is a keywords and some keywords are synonymous (they are linked in Link table). The trouble is that synonyms can be linked in two directions.
Example there is keywords A and B, (they are synonyms). In Links table they can linked by two directions:
Keyword 1 | Keyword 2
-----------------------
A | B
Or
Keyword 1 | Keyword 2
-----------------------
B | A
Both variants are equals.
There is class Keyword with method
Code:
public Set<Keyword> getSynonyms()
Is needed to write a map file! getSynonyms() must return a set of synonyms (Keyword instances) wich linked with current keyword by any directions.
I have write this in map file...
Code:
<class name="Keyword" table="keywords">
<id name="id" column="id">
<generator class="org.hibernate.id.IdentityGenerator"/>
</id>
<property name="keyword" column="keyword"/>
<set name="synonyms" table="links" lazy="true" cascade="save-update">
<key column="keyword1"/>
<many-to-many column="keyword2"
class="Keyword"/>
</set>
</class>
But it is wrong, because will loaded only part of all related keywords... Have any ideas?