1

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>

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?

This properties is in a joined subclass. TIA Adb

Andreanta
  • 175
  • 1
  • 8

2 Answers2

4

Instead of marking it as optional you can try mark it as inverse http://nhibernate.info/doc/nh/en/index.html#mapping-declaration-join

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">
Owen Pauling
  • 11,349
  • 20
  • 53
  • 64
Vadim
  • 17,897
  • 4
  • 38
  • 62
0

You cannot save a record on a view, on your class try adding the mutable='false'

<class name="ActorView" mutable="false">
...

If you are trying to save back then I suspect you will need to forget about the view and turn it into a fully blown entity with collections defined.

Rippo
  • 22,117
  • 14
  • 78
  • 117