Nhibernate/hibernate避免在联接表或视图中插入 [英] Nhibernate/hibernate Avoid Insert in joined table or view
问题描述
我必须加入一个具有视图的实体才能将一些数据检索到属性中
I have to join a entity with a view to retrieve some data into properties
<join table="XXVIEW" optional="true">
<key column="ID_ENT" />
<property name="Prop1" insert ="false" update ="false" />
<property name="Prop2" insert ="false" update ="false" />
<property name="Prop3" insert ="false" update ="false" />
</join>
但是当我尝试保存(插入)时失败,因为它尝试在具有ID_Ent的XXVIEW中插入一条记录
But when i try to save (insert) it fails becouse it try to insert a record in XXVIEW with ID_Ent
我需要在这个实体中具有一些属性,这些属性是通过各种计算或联接获得的,并且必须具有单个属性,而不是像组件这样的对象属性.
I need to have some properties in this entity get from various calculations or joins and to have as single properties non in a object property like a component.
我可以跳过此插入吗???还是可以用其他方式映射此属性?
Can i skip this insert ??? or can i map this properties in other way?
此属性在连接的子类中. TIA 亚行
This properties is in a joined subclass. TIA Adb
推荐答案
Instead of marking it as optional you can try mark it as inverse http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-join
反之(可选-默认为 false):如果启用,则Hibernate将不会 尝试插入或更新属性 由该联接定义.
inverse (optional - defaults to false): If enabled, Hibernate will not try to insert or update the properties defined by this join.
<join table="XXVIEW" inverse="true">
这篇关于Nhibernate/hibernate避免在联接表或视图中插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!