-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Association fields are not being inserted
PostPosted: Mon Jan 22, 2007 3:28 pm 
Beginner
Beginner

Joined: Tue Sep 05, 2006 2:36 pm
Posts: 24
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.