我需要配置Set.hbm.xml文件以映射此表:
表“Set”[PK:IdSet int PK:dProject int 单位字符 NumDisc int]
表“项目”[PK:IdProject int 名称varchar DateBegin日期时间 DateEnd datetime]
我有这个配置,问题是不工作,mappinn错误......
这是SET.hbm.xml
<composite-id>
<key-property name="IdSet" column="IdSet" class="Set"></key-property>
<key-many-to-one class="Project" name="IdProject" column="IdProject" ></key-many-to-one>
</composite-id>
<property name="IdSetState" />
<property name="IdPriority" />
<property name="Unit" />
<property name="NumDisc" />
<property name="NumSet" />
这是Set实体类:
public class Set
{
public virtual int IdSet { get; set; }
public virtual int IdProject { get; set; }
public virtual int IdSetState { get; set; }
public virtual int IdPriority { get; set; }
public virtual char Unit { get; set; }
public virtual int NumDisc { get; set; }
public virtual int NumSet { get; set; }
}
如何配置?
答案 0 :(得分:0)
你确定它是“Key”而不是“key-property”吗?
<composite-id>
<key-property name="IdSet" column="IdSet" lazy="proxy" class="Set"></key>
<key-many-to-one name="IdProject" column="IdProject" lazy="proxy"
class="Project"></key-many-to-one>
</composite-id>
答案 1 :(得分:0)
您确定必须指定class="Set"
吗? Id的类型为int,您可以将其删除
<composite-id>
<key-property name="IdSet" column="IdSet"></key-property>
</composite-id>
int IdProject
也应该是Project Project
?