title: How can i saveOrUpdate in hibernate where the changed field is not the id
body: <p>The scenario is :</p>
  
  <p>The id is identity generated. I have a field "key" (not id)which i need to check while saveOrUpdate. If "Key" is changed, i need to update the database with the updated key and value. So the scenario becomes like, i want to update the database based on a particular field(here "key") change and not the id value change.</p>
  
  <pre><code>&lt;class name="Data" table="DATA"&gt;
       &lt;id name="id" type="java.lang.Long"&gt;
          &lt;column name="id" /&gt;
          &lt;generator class="identity" /&gt;
      &lt;/id&gt;    
      &lt;property name="Key" type="string" not-null="true" index="dedupeKey_Index"&gt;
          &lt;column name="Key" length="100" /&gt;
      &lt;/property&gt;
  
      &lt;property name="Value" type="string"&gt;
          &lt;column name="Value" length="100" /&gt;
      &lt;/property&gt;
  
      &lt;property name="insertedDate"
          type="org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime"&gt;
          &lt;column name="insertedDate" /&gt;
      &lt;/property&gt; 
  
  
  &lt;/class&gt;
  </code></pre>
  
  <p>How can i do this?Is there any way to forcefully make hibernate make my field "key" to refer while saveOrUpdate and not the id!!</p>
  
  <p>I thought of making a composite key. But then I cant create a generator for "id", which is required!!</p>
  
  <p>Thanks guys in advance!!</p>