开发者

composite id mapping configuration

开发者 https://www.devze.com 2023-03-12 15:22 出处:网络
I need configure the Set.hbm.xml file for mapping this table: TABLE \"Set\" [PK: IdSet int PK: dProject int

I need configure the Set.hbm.xml file for mapping this table:

TABLE "Set" [PK: IdSet int PK: dProject int Unit char NumDisc int]

TABLE "Project" [PK: IdProject int Name varchar DateBegin datetime DateEnd datetime]

I have this configuration, the problem is that don't work, mappinn error...

THIS IS THE SET.hbm.xml

<composite-id>
  <key-property name="IdSet" column="IdSet"  class="Set">&开发者_JAVA技巧lt;/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" />

THIS IS THE Set entity class:

   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; }
}

How can configure this??


Are you sure that it is "Key" and not "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>

NHibernate and Composite Keys


are you sure you have to specify class="Set"? Id is of type int , you could remove it

<composite-id>
  <key-property name="IdSet" column="IdSet"></key-property>
</composite-id>

also int IdProject should be Project Project?

0

精彩评论

暂无评论...
验证码 换一张
取 消