This list is for the development OF NHibernate only. You should be using <many-to-one>. Read the official docs ( http://www.nhforge.org/doc/nh/en/index.html)
Diego On Wed, Jul 25, 2012 at 5:14 AM, Shwetamber <[email protected]> wrote: > Hello , > > I have 2 tables Category & Product . > > tblCategory : tblProduct > > CategoryId (PK) ProductId (PK) > CategoryName ProductName > CategoryId (FK) > > Now i have problem in mapping with Product Table I don't know how to map > CategoryId of product table. I done something but its not working > > Products.hbm.xml file > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > namespace="Test_NHibernate_Join_Tables" > assembly="Test_NHibernate_Join_Tables" > > > <class name="Test_NHibernate_Join_Tables.Products" table="tblProducts"> > <id name="ProductId" type="int"> > <generator class="native"/> > </id> > <property type="string" name="ProductName" > > <column name="ProductName"></column> > </property> > <set name="Category" inverse="true" cascade="all" > > <key column="CategoryId" /> > <one-to-many class="Test_NHibernate_Join_Tables.Products"/> > </set> > </class> > > </hibernate-mapping> > > And my Product.cs File is > > public class Products > { > > public virtual int? ProductId { get; set; } > Category _category; > public virtual Category Category > { > get > { > return _category; > } > set > { > _category = value; > } > } > public virtual string ProductName { get; set; } > } > > Thanks & Regards > Shwetamber > > >
