Hibernate: "index" for "map" not working for me
From: Wordster (ronnie_diaz_at_hotmail.com)
Date: 01/13/05
- Next message: mischka: "Distributed Java transactions with JTA and JTS (and possibly OTS)"
- Previous message: Gluon: "[long][dbunit/mysql] org.dbunit.dataset.NoSuchColumnException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 13 Jan 2005 11:29:06 -0800
With the following mapping:
<subclass name="Card" discriminator-value="CARD">
<map name="metaNodesMap" inverse="true">
<key column="cardId"/>
<index column="associated_node_id" type="long"/>
<one-to-many class="NodeMeta"/>
</map>
</subclass>
... and the following mapping for my NodeMeta class:
<class name="NodeMeta" table="NODE_META">
<id name="id" type="long" unsaved-value="null">
<column name="NODE_META_ID" sql-type="number" not-null="true"/>
<generator class="sequence"/>
</id>
<property name="defaultExpand"/>
<many-to-one name="card" column="cardId" not-null="true"/>
</class>
The value belonging to "associated_node_id" never gets persisted to the
database.
I run the following code:
Card card = new Card();
card.setName("Test Mapping");
session.save(card);
Map metaNodesMap = card.getMetaNodesMap();
NodeMeta meta = new NodeMeta();
meta.setCard(card);
metaNodesMap.put(new Long(901), meta);
session.save(meta);
session.flush();
transaction.commit();
In the database, a "Card" row is created and a "NodeMeta" row is
created. Everything looks fine, except the "associated_node_id" in the
NodeMeta table never gets updated with the number "901". It's just
blank. When I tried to retrieve the Card instance, I get an error
saying "null index column for collection".
Does anyone know what I'm doing wrong? Thanks.
-Ronnie
- Next message: mischka: "Distributed Java transactions with JTA and JTS (and possibly OTS)"
- Previous message: Gluon: "[long][dbunit/mysql] org.dbunit.dataset.NoSuchColumnException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|