2009-11-26 72 views
3

我試圖根據本教程安裝nhibernate,但它沒有說我應該在哪裏放置Cat.hbm.xml文件以及項目應該如何理解它的項目部分。我應該在哪裏放NHibernate hibernate-mapping xml文件?

<?xml version="1.0" encoding="utf-8" ?> 
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" 
namespace="QuickStart" assembly="QuickStart"> 
<class name="Cat" table="Cat"> 
<!-- A 32 hex character is our surrogate key. It's automatically 
generated by NHibernate with the UUID pattern. --> 
<id name="Id"> 
<column name="CatId" sql-type="char(32)" not-null="true"/> 
<generator class="uuid.hex" /> 
</id> 
<!-- A cat has to have a name, but it shouldn' be too long. --> 
<property name="Name"> 
<column name="Name" length="16" not-null="true" /> 
</property> 
<property name="Sex" /> 
<property name="Weight" /> 
</class> 
</hibernate-mapping> 

https://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/pdf/nhibernate_reference.pdf

+0

或者,使用Fluent NH,您可以在內存中生成映射/將它們傳輸到會話工廠... – dotjoe 2011-05-06 13:48:06

回答

8

項目創建一個文件夾資源或映射。把所有的映射文件到該文件夾​​和存儲那些組件通過在項目中添加他們作爲「建設行動=嵌入的資源」