问题描述
现在,你说之前:我做了谷歌和我的的hbm.xml
文件是嵌入的资源。
下面是code,我呼吁:
的ISession会话=的getCurrentSession();
VAR返回object = session.Get< T>(同上);
下面是我的映射文件类:
< XML版本=1.0编码=UTF-8&GT?;<休眠映射的xmlns =金塔:NHibernate的映射 - 2.2> <类名=HQData.Objects.SubCategory,HQData表=子类别懒惰=真正的> < ID名称=ID列=ID未保存值=0> <生成器类=身份/> < / ID> <属性名=姓名一栏=名称/> <属性名=NumberOfBuckets列=NumberOfBuckets/> <属性名=SearchCriteriaOne列=SearchCriteriaOne/> <包名=_企业级联=全> <键列=SubCategoryId/> &其中;一对许多 类=HQData.Objects.Business,HQData/> < /袋> <包名=_水桶级联=全> <键列=SubCategoryId/> &其中;一对许多 类=HQData.Objects.Bucket,HQData/> < /袋> < /类>< /休眠映射>
有没有人跑这个问题?
下面是完整的错误消息:
更新,这里就是为解决方案的我的场景是:我已经改变了一些code和运行过程中我并没有增加大会的配置文件。
听起来像是你忘了一个测组件添加到会话出厂配置。
如果你使用的app.config ...
。
。
<属性名=show_sql>真< /性>
<属性名=query.substitutions>真1,假0,是'Y',没有'N'< /性>
<测组件=Project.DomainModel/> <! - 查看 - >
< /会话工厂>
。
。
Now, before you say it: I did Google and my hbm.xml
file is an Embedded Resource.
Here is the code I am calling:
ISession session = GetCurrentSession();
var returnObject = session.Get<T>(Id);
Here is my mapping file for the class:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HQData.Objects.SubCategory, HQData" table="SubCategory" lazy="true">
<id name="ID" column="ID" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Name" column="Name" />
<property name="NumberOfBuckets" column="NumberOfBuckets" />
<property name="SearchCriteriaOne" column="SearchCriteriaOne" />
<bag name="_Businesses" cascade="all">
<key column="SubCategoryId"/>
<one-to-many
class="HQData.Objects.Business, HQData"/>
</bag>
<bag name="_Buckets" cascade="all">
<key column="SubCategoryId"/>
<one-to-many
class="HQData.Objects.Bucket, HQData"/>
</bag>
</class>
</hibernate-mapping>
Has anyone run to this issue before?
Here is the full error message:
Update, here's what the solution for my scenario was: I had changed some code and I wasn't adding the Assembly to the config file during runtime.
Sounds like you forgot to add a mapping assembly to the session factory configuration..
If you're using app.config...
.
.
<property name="show_sql">true</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<mapping assembly="Project.DomainModel"/> <!-- Here -->
</session-factory>
.
.
这篇关于NHibernate.MappingException:没有持留为:XYZ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!