开发者

Nhibernate 3.0:Mapping in the hbm.xml file for a relational table step by step procedure needed

I'm using an Nhibernate version 3.0 and this is my first time im using it.I would like to know how can i create an hbm.xml file for the tables where relationship exists between them. Here is my scenario i have two tables named table A and table B. Table B primary key is the foriegn key in the table A. for this how i 开发者_Go百科need to write the hbm file and also how i need to insert the values into both the tables simultaneously by using only one object. (ie., how should i need to write the table A class file and table B class file.)

if any one explains me in the set by step procedure it will be easier for me to understand.


This is covered in the NH doc. The relationship you are talking is a <many-to-one/>, search for it here:

http://knol.google.com/k/fabio-maulo/nhibernate-chapter-5-basic-o-r-mapping/1nr4enxv3dpeq/8#

you will find some examples. In order to have the intellisense inside Visual Studio when you write the HBM files, you can copy these files

nhibernate-configuration.xsd
nhibernate-mapping.xsd 

in the C:\Programme\Microsoft Visual Studio xxx\Xml\Schemas path.

In order to save simultaneously the referred entity you have to ensure to apply cascade="save-update" on the <many-to-one/> tag.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜