NHibernate.MappingException: Unknown entity class: QuickStart.Cat

zbluestar 2007-06-12 10:23:35
异常详细信息: NHibernate.MappingException: Unknown entity class: QuickStart.Cat

源错误:


行 28: princess.Weight = 7.4f;
行 29:
行 30: session.Save(princess);
行 31: tx.Commit();

文件: c:\inetpub\wwwroot\quickstart\webform1.aspx.cs 行: 30


cat.hbm.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>

web.config文件

<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<!-- Add this element -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2000Dialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Server=(local);database=NHibernate;user id=sa;password=sa</property>
<property name="hibernate.connection.driver_class">NHibernate.Driver.SqlClientDriver</property>

<mapping assembly="QuickStart" />
</session-factory>
</hibernate-configuration>

cat类:
public class Cat
{
private string id;
private string name;
private char sex;
private float weight;

public Cat()
{

}

public string Id
{
get { return id; }
set { id = value; }
}

public string Name
{
get { return name; }
set { name = value; }
}

public char Sex
{
get { return sex; }
set { sex = value; }
}

public float Weight
{
get { return weight; }
set { weight = value; }
}
}

请教各位:为什么出现上面如标题所示得问题啊?急.

...全文
1947 7 打赏 收藏 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuzhongxf 2008-01-23
  • 打赏
  • 举报
回复
问题解决了吗?
mingjunr 2007-06-13
  • 打赏
  • 举报
回复
选中xml文件右键属性里有
zbluestar 2007-06-13
  • 打赏
  • 举报
回复
写成<class name="QuickStart.Cat" table="Cat">这个也试过了。
怎么才能设为嵌入式资源呢?
mingjunr 2007-06-13
  • 打赏
  • 举报
回复
另外要设为嵌入式资源之类的
mingjunr 2007-06-13
  • 打赏
  • 举报
回复
<class name="Cat" table="Cat">
我一般都写成<class name="QuickStart.Cat" table="Cat">
别处没看出什么不妥来
zbluestar 2007-06-12
  • 打赏
  • 举报
回复
public sealed class NHibernateHelper
{
private const string CurrentSessionKey = "nhibernate.current_session";
private static readonly ISessionFactory sessionFactory;

static NHibernateHelper()
{
Configuration cfg = new Configuration().Configure();
cfg.AddAssembly("QuickStart");
sessionFactory = cfg.BuildSessionFactory();
}

public static ISession GetCurrentSession()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[CurrentSessionKey] as ISession;
if (currentSession == null)
{
currentSession = sessionFactory.OpenSession();
context.Items[CurrentSessionKey] = currentSession;
}
return currentSession;
}

public static void CloseSession()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[CurrentSessionKey] as ISession;
if (currentSession == null)
{
// No current session
return;
}
currentSession.Close();
context.Items.Remove(CurrentSessionKey);
}

public static void CloseSessionFactory()
{
if (sessionFactory != null)
{
sessionFactory.Close();
}
}
}



private void Page_Load(object sender, System.EventArgs e)
{
ISession session = NHibernateHelper.GetCurrentSession();
ITransaction tx = session.BeginTransaction();

Cat princess = new Cat();
princess.Name = "Princess";
princess.Sex = 'F';
princess.Weight = 7.4f;

session.Save(princess);
tx.Commit();

NHibernateHelper.CloseSession();
}
canybox 2007-06-12
  • 打赏
  • 举报
回复
多贴点代码啊。。。。
内容概要:本文围绕基于混沌系统与DNA编码的彩色图像加密解密体系展开研究,提出了一种多层级、高复杂度的复合加密方法。该方法深度融合混沌系统的伪随机遍历特性与DNA编码的高维并行处理能力,对彩色图像RGB三通道像素信息实施双重混淆与扩散操作,显著增强了加密算法的安全性与抗攻击能力。研究系统性地构建了完整的加密-解密流程,并重点针对实际传输环境中常见的高斯噪声、椒盐噪声及多种裁剪攻击(包括小面积、中面积、边缘与中心区域裁剪)进行了详尽的鲁棒性测试。实验结果表明,该算法不仅具备极高的密钥敏感性与安全性,而且在遭受不同程度噪声干扰或局部数据丢失后,仍能有效恢复出具有清晰结构与可用信息的解密图像,展现出卓越的容错性与实用性。; 适合人群:具备一定图像处理、信息安全或密码学基础知识的科研人员、研究生及从事多媒体安全传输开发的工程技术人员。; 使用场景及目标:①应用于军事通信、医疗影像保护、数字版权管理等对安全性要求极高的图像传输与存储场景;②为新型图像加密算法的设计提供创新思路,并为算法的抗干扰性能评估建立系统化测试体系,推动复合加密技术向工程化、实用化发展。; 阅读建议:建议读者结合Matlab代码实现,复现文中所述的加密流程与抗干扰测试,深入理解混沌序列生成、DNA编码规则映射、像素扩散机制等关键步骤,并可通过调整参数或引入新的攻击类型来进一步拓展算法的性能分析。

111,128

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧