-->
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: getting null values in Child table
PostPosted: Fri Sep 11, 2009 8:13 am 
Beginner
Beginner

Joined: Sat Aug 01, 2009 6:44 am
Posts: 24
--------------------------------This is my parent class---------------------------------

public class Item
{
private int _ITEM_ID;
private string _Name;
private string _Description;
private ISet bids = new HashedSet();

public virtual ISet Bids
{
get { return bids; }
set { bids = value; }
}
public virtual void addBid(Bid bid)
{
bid.itemvar = this;
bids.Add(bid);
}
}


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DTO" namespace="Business.Entities">
<class name="Business.Entities.Item" table="ITEM">

<id name="ITEM_ID" column="ITEM_ID" type="Int32" unsaved-value="null">
<generator class="native"/>
</id>
<set name="Bids" inverse="true" cascade="all-delete-orphan">
<key column="ITEM_ID"></key>
<one-to-many class="Bid"/>
</set>
<property column="Name" type="string" name="Name" />
<property column="Description" type="string" name="Description" />
</class>
</hibernate-mapping>

-----------------------------------------This is my child class-----------------------------------


public class Bid
{
private int _BID_ID;
private int _Amount;
private int _ITEM_ID;
private Item _itemvar;
}

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DTO" namespace="Business.Entities">
<class name="Business.Entities.Bid" table="BID">

<id name="BID_ID" column="BID_ID" type="Int32" unsaved-value="null">
<generator class="native"/>
</id>
<many-to-one name="itemvar" column="ITEM_ID" class="Item" not-null="false">
</many-to-one>

<property column="Amount" type="int" name="Amount" />
</class>
</hibernate-mapping>

---------------This is where i am calling my methods to save data in to child-------------------------



Bid bid = new Bid();
bid.Amount = 100;

Item item = new Item();
item.Name = "jewlry";
item.Description = "Its kool man";

item.addBid(bid);

DAL.DAL pub = new DAL.DAL();
pub.addItems(item);




public void addBids(Bid bid)
{
try
{
session.Save(bid);
session.Flush();
}
catch (Exception ex)
{
throw ex;
}
}




Can any body Tell me how to Fix this... i tried my best at net and book but didn't find ans... i can insert values in Parent.. but cant insert value in Child... its putting null there... ANY Solution will be greatly appreciated


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.