-->
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: Cascading save not happening to its association.
PostPosted: Tue Jun 09, 2009 9:44 pm 
Newbie

Joined: Wed Sep 10, 2008 1:01 pm
Posts: 6
I have a bi-directional association between Item class and Bid class. (based upon An Item can contain many Bids)

<!--Mappings are as follows -->

<class name="com.hibernateproject.domain.Item" table="ITEM">
<id name="iid" type="int" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="itemName" type="string"/>
<list name="bids" inverse="true" cascade="all" table="BID">
<key column="item_bid"/>
<index column="index_column"/>
<one-to-many class="com.hibernateproject.domain.Bid" />
</list>
</class>

<class name="com.hibernateproject.domain.Bid" table="BID">
<id name="bid" type="int" unsaved-value="null">
<generator class="increment"/>
</id>
<property name="bidValue" type="long" />
<many-to-one name="item" column="item_bid" class="com.hibernateproject.domain.Item"
not-null="true"/>
</class>

<!--Tables are as follows:-->

create table item(iid number, itemName varchar(20));
create table bid(bid number, bidValue long, item_bid number, index_column number);

<!--Main Class for Saving Item cascading Bid -->
session.beginTransaction();

Item item = new Item();
item.setItemName("Item2");
item.setBids(new ArrayList());
Bid bid = new Bid(2000);
bid.setItem(item);
item.getBids().add(bid);
session.save(item);

session.getTransaction().commit();

My mapping files are in the classpath. It is not cascading Bid class. Instead, it is executing SQL as follows:
Hibernate: select max(iid) from ITEM
Hibernate: insert into ITEM (itemName, iid) values (?, ?)
Hibernate: update BID set bidValue=?, item_bid=? where bid=?

Please suggest.


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.