Hibernate version: 2.1.7
Mapping documents:
<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
<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>
Code between sessionFactory.openSession() and session.close():
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();
Name and version of the database you are using: Oracle
The generated SQL (show_sql=true):
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into SCORECARD_NODE (NAME, folderId, shortName, backEndName, backEndFieldName, passNumber, targetNumber, operator, trendRange, trendFromDate, trendToDate, decimalDigit, currencySymbol, percentSymbol, nodeType, SCORECARD_NODE_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'SCORECARD', ?)
Hibernate: insert into SCORECARD_NODE_META (defaultExpand, scorecardId, SCORECARD_NODE_META_ID) values (?, ?, ?)
My Issue:
When I run the code, a row for both the Card and NodeMeta object gets persisted in the database, but the "associated_node_id" column always appear blank. In this code example, I thought that the number "901" should be placed.
What am I doing wrong? Thanks.
-Ronnie
|