Code:
<class table="ent" name="Ent">
<id name="id">
<generator class="assigned"/>
</id>
<property name="name"/>
<set name="linkedObjects" table="ent_relations" >
<key column="id1"/>
<many-to-many class="Ent" column="id2"/>
</set>
</class>
Code:
public class Ent {
private int id;
String name;
Set linkedObjects;
public int getId(){
return id;
}
public void setId( int id ){
this.id = id;
}
public String getName(){
return name;
}
public void setName( String name ){
this.name = name;
}
public Set getLinkedObjects(){
return linkedObjects;
}
public void setLinkedObjects( Set linkedObjects ){
this.linkedObjects = linkedObjects;
}
}
Code:
CREATE TABLE ent (
id int PRIMARY KEY,
name varchar(50)
);
CREATE TABLE ent_relations (
id1 int,
id2 int
);