• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

native generator class not editable

 
TR Smith
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To begin with, we are actually having this problem with NHibernate (don't shoot me), but I've also got parallel projects using Hibernate that will soon be crossing the same bridge.

We have a table where fields (non-primary key) cannot be updated. The primary key is an auto-generated integer. When looking at the SQL generated behind the scenes, it is putting the primary key field in the update statement. Below is a little snippet from our mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Moon" namespace="Moon">
<class name="Partnership" table="TblPartnership" lazy="true">

<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>

<property column="F1002" type="String" name="ShortName" not-null="true" length="35" />


We are simply trying to update F1002 and the SQL is failing (it is trying the statement UPDATE TblPartnership SET F1002='xxxx' and pshipID='xxx' where pshipid='xxx'). The Id field cannot be changed as it is a foreign key in many other tables.

Any ideas on how to fix this problem?
 
Rodrigo Lopes
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try to add updatable = false in the id definition, although I think it should not be necessary.

<id name="Id" column="ID" type="Int32" unsaved-value="0" updatable = false>
<generator class="native"/>
</id>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic