Nhibernate报错集合类型转换错误!

dh1314al 2010-04-05 11:29:38
这我的实体类映射文件

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="MyBookShop.Model.Book, MyBookShop.Model" table="Books">
<id name="Id" type="Int32" unsaved-value="null">
<column name="Id" length="4" sql-type="int" not-null="true" unique="true" index="PK_Book"/>
<generator class="native" />
</id>
<property name="Title" type="String">
<column name="Title" length="200" sql-type="nvarchar" not-null="true"/>
</property>
<property name="Author" type="String">
<column name="Author" length="200" sql-type="nvarchar" not-null="true"/>
</property>
<property name="PublishDate" type="DateTime">
<column name="PublishDate" length="8" sql-type="datetime" not-null="true"/>
</property>
<property name="ISBN" type="String">
<column name="ISBN" length="50" sql-type="nvarchar" not-null="true" unique="true" index="IX_Books_ISBN"/>
</property>
<property name="WordsCount" type="Int32">
<column name="WordsCount" length="4" sql-type="int" not-null="true"/>
</property>
<property name="UnitPrice" type="Decimal">
<column name="UnitPrice" length="8" sql-type="money" not-null="true"/>
</property>
<property name="ContentDescription" type="String">
<column name="ContentDescription" sql-type="nvarchar" not-null="false"/>
</property>
<property name="AurhorDescription" type="String">
<column name="AurhorDescription" sql-type="nvarchar" not-null="false"/>
</property>
<property name="EditorComment" type="String">
<column name="EditorComment" sql-type="nvarchar" not-null="false"/>
</property>
<property name="TOC" type="String">
<column name="TOC" sql-type="nvarchar" not-null="false"/>
</property>
<property name="Clicks" type="Int32">
<column name="Clicks" length="4" sql-type="int" not-null="true"/>
</property>
<many-to-one name="Category" class="MyBookShop.Model.Category, MyBookShop.Model" foreign-key="FK_Book_Category">
<column name="CategoryId" length="4" sql-type="int" not-null="true"/>
</many-to-one>
<many-to-one name="Publisher" class="MyBookShop.Model.Publisher, MyBookShop.Model" foreign-key="FK_Books_Publishers">
<column name="PublisherId" length="4" sql-type="int" not-null="true"/>
</many-to-one>
<bag name="BookReaderCommentses" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="BookId"/>
<one-to-many class="MyBookShop.Model.ReaderComment, MyBookShop.Model"/>
</bag>
</class>
</hibernate-mapping>

这我的实体类

using System;
using System.Collections.Generic;
using System.Text;

namespace MyBookShop.Model
{
[Serializable()]
public class Book
{
#region 字段
private int id;
private string title;
private string author;
private Publisher publisher;
private DateTime publishDate;
private string iSBN;
private int wordsCount;
private int unitPrice;
private string contentDescription;
private string aurhorDescription;
private string editorComment;
private string tOC;
private Category category;
private int clicks;
private List<ReaderComment> bookReaderCommentses = null;
#endregion
#region 属性

public virtual List<ReaderComment> BookReaderCommentses
{
get { return bookReaderCommentses; }
set { bookReaderCommentses = value; }
}
public virtual string ContentDescription
{
get { return contentDescription; }
set { contentDescription = value; }
}
public virtual DateTime PublishDate
{
get { return publishDate; }
set { publishDate = value; }
}
public virtual int Clicks
{
get { return clicks; }
set { clicks = value; }
}

public virtual Category Category
{
get { return category; }
set { category = value; }
}

public virtual string TOC
{
get { return tOC; }
set { tOC = value; }
}
public virtual string EditorComment
{
get { return editorComment; }
set { editorComment = value; }
}
public virtual string AurhorDescription
{
get { return aurhorDescription; }
set { aurhorDescription = value; }
}
public virtual int UnitPrice
{
get { return unitPrice; }
set { unitPrice = value; }
}

public virtual int WordsCount
{
get { return wordsCount; }
set { wordsCount = value; }
}

public virtual string ISBN
{
get { return iSBN; }
set { iSBN = value; }
}

public virtual Publisher Publisher
{
get { return publisher; }
set { publisher = value; }
}

public virtual string Author
{
get { return author; }
set { author = value; }
}

public virtual string Title
{
get { return title; }
set { title = value; }
}

public virtual int Id
{
get { return id; }
set { id = value; }
}
#endregion
}
}

报错信息:注:不是配置的问题,我执行增、删、改、查都可以唯独查的类中包含集合的时候就报转换无效!我知道什么原因请给位指教!报错信息不完整的话 加QQ:498795832 详聊 在线等!!!!非常急
Message:Invalid Cast (check your mapping for property type mismatches); setter of MyBookShop.Model.Book
InnerException:{"指定的转换无效。"}
StackTrace: 在 (Object , Object[] , SetterCallback )
在 NHibernate.Bytecode.Lightweight.AccessOptimizer.SetPropertyValues(Object target, Object[] values)
在 NHibernate.Tuple.Entity.PocoEntityTuplizer.SetPropertyValuesWithOptimizer(Object entity, Object[] values)
...全文
364 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dh1314al 2010-04-05
  • 打赏
  • 举报
回复
怎么没高手指教了????

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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