That's my problem.
Tables:
Code:
bots
****
botid
name
dictionaries
**********
dictionaryid
name
bot_by_dictionary
***************
botid
dictionaryid
listindex
Classes:Code:
public class Bot{
Long id;
List<Dictionary> dictionaries;
}
public class Dictionary{
Long id;
String name;
}
Mapping files:Code:
<class name="Bot" table="bots">
<cache usage="read-write"/>
<id name="id" column="botId">
<generator class="native" />
</id>
<property name="name"/>
<list name="dictionaries" inverse="true" table="bot_by_dictionary" lazy="false" cascade="save-update">
<key column="botId" unique="true" />
<list-index column="listIndex" base="0" />
<many-to-many column="dictionaryId" class="Dictionary"/></list>
</class>
<class name="Dictionary" table="dictionaries">
<cache usage="read-write"/>
<id name="id" column="dictionaryId">
<generator class="native" />
</id>
<property name="name"/>
</class>
If I manually insert data directly to the database, I can retrieve the Bot instance with its dictionaries without problem.
But, if I create a new Bot, then set a list of dictionares and save the bot I get the Bot and the Dictionary saved, but, the table bot_by_dictionary remains with 0 rows.
Any idea about this behavior?