-->
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.  [ 2 posts ] 
Author Message
 Post subject: "Map" and "Index" issue with Hibernate
PostPosted: Thu Jan 13, 2005 3:52 pm 
Newbie

Joined: Thu Jan 13, 2005 3:46 pm
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 13, 2005 3:59 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
search about bidirectionnal association and indexed collection, there is a wiki about this, you have all explanation in hibernate in action too

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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

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.