问题描述
View:Grid_View
>我的Hibernate hbm文件
<休眠映射>
< class name =hibernate.domain.Viewtable =Grid_Viewmutable =false>
< property name =ACCT_BR_CDtype =string>
< column name =ACCT_BR_CD/>
< / property>
< property name =ACCT_NOtype =string>
< column name =ACCT_NO/>
< / property>
< property name =LGL_ENTY_NMtype =string>
< column name =LGL_ENTY_NM/>
< / property>
< property name =CUST_CTRY_CDtype =string>
< column name =CUST_CTRY_CD/>
< / property>
< property name =ACCT_SRC_SYS_CDtype =string>
< column name =ACCT_SRC_SYS_CD/>
< / property>
< / class>
< / hibernate-mapping>
>因为他们在我看来并不是主键,所以我没有提到我的id字段映射。
但是在hibernate id中是必需的。
>我的问题
如何在hibernate映射文件中继续使用没有id的映射。
他们没有独特价值的专栏,所以他们没有任何机会让他们成为关键。请帮助我解决此问题
< id column =ROWIDtype =string/>
Hibernate需要映射的唯一键。最好的方法是添加主键。
View : Grid_View
> My Hibernate hbm file
<hibernate-mapping>
<class name="hibernate.domain.View" table="Grid_View" mutable="false">
<property name="ACCT_BR_CD" type="string">
<column name="ACCT_BR_CD"/>
</property>
<property name="ACCT_NO" type="string">
<column name="ACCT_NO"/>
</property>
<property name="LGL_ENTY_NM" type="string">
<column name="LGL_ENTY_NM"/>
</property>
<property name="CUST_CTRY_CD" type="string">
<column name="CUST_CTRY_CD"/>
</property>
<property name="ACCT_SRC_SYS_CD" type="string">
<column name="ACCT_SRC_SYS_CD"/>
</property>
</class>
</hibernate-mapping>
> As their is no primary key in my view,Ihave not mentioned id field in my mapping. But in hibernate id is required.
> My Question
How to proceed with the mapping without id in the hibernate mapping file.And their are no columns with unique values so thier is no any chance of making them the key. Please help me resolve this issue
You have two options either add Composite Key or add
<id column="ROWID" type="string" />
Hibernate need unique key to map. Best approach is to add primary key.
这篇关于在hibernate xml映射中映射没有主键的数据库视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!