我得到了
“MappingExecption:ProjectNameImportTypeProxy 没有持久性”
在实体上,但仅在更新它时。
我的意思是,我创建没有问题的实体。如果我重新加载它并再次保存它,我会得到异常,这意味着映射实际上是正确的..
如果我删除了 lazy="true" 映射选项,我不会收到此错误。
这是映射:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="ProjectName"
namespace="Projects.ProjectName.Model">
<class name="ProjectNameImportType" table="mid_ProjectNameImportTypes">
<id name="ID" column="ID">
<generator class="hilo"/>
</id>
<property name="Code" length="255" not-null="true" index="idx_ProjectNameImportType_Code"/>
<property name="Name" length="255" not-null="true" />
<property name="Description" length="2000" />
<property name="FilesShare" length="2000" not-null="true" />
<property name="ZippedAssemblies" lazy="true" type="BinaryBlob" not-null="true" />
<property name="FileName" length="255" not-null="true" />
</class>
</hibernate-mapping>
这是课程:
/// <summary>
/// Represents a projectName import type
/// </summary>
[UniqueEntityKey("Code")]
public class ProjectNameImportType : ModelEntityBase
{
/// <summary>
/// Get and set code
/// </summary>
[Required]
[StringLength(255)]
public virtual string Code { get; set; }
/// <summary>
/// Get and set name
/// </summary>
[Required]
[StringLength(255)]
public virtual string Name { get; set; }
/// <summary>
/// Get and set description
/// </summary>
[StringLength(2000)]
public virtual string Description { get; set; }
/// <summary>
/// Get and set files share
/// </summary>
[Required]
[StringLength(2000)]
public virtual string FilesShare { get; set; }
/// <summary>
/// Get and set zipped assemplies data
/// </summary>
[Required]
public virtual byte[] ZippedAssemblies { get; set; }
/// <summary>
/// Get and set filename
/// </summary>
[Required]
[StringLength(255)]
public virtual string FileName { get; set; }
}
我究竟做错了什么?