title: How to execute an update via SQLQuery in Hibernate
body: <p>I need to update a joined sub-class. Since Hibernate doesn't allow to update joined sub-classes in hql or named-query I want to do it via SQL. I also can't use a sql named-query because updates via named-query are not supported in Hibernate.</p>
  
  <p>So I decided to use a SQLQuery. But Hibernate complaints about not calling addScalar():</p>
  
  <blockquote>
    <p>org.hibernate.QueryException: addEntity() or addScalar() must be called on a sql query before executing the query.</p>
  </blockquote>
  
  <p>Are updates returning the number of rows affected and how is named that column?</p>
  
  <p>Are there any other ways to do an update on a joined sub-class in hibernate?</p>
  
  <p>Here is a brief example of what i'm trying to do:</p>
  
  <pre><code>&lt;hibernate-mapping&gt;  
          &lt;class name="example.NiceClass" table="NICE_CLASS"&gt;  
    &lt;meta attribute="class-code"&gt;&lt;/meta&gt;  
    &lt;id name="id" type="java.lang.Long"&gt;  
     &lt;column name="NICE_CLASS_ID" precision="8" /&gt;  
     &lt;generator class="sequence"&gt;  
      &lt;param name="sequence"&gt;NICE_CLASS_SEQ&lt;/param&gt;  
     &lt;/generator&gt;  
    &lt;/id&gt;  
      &lt;/class&gt;  
  &lt;/hibernate-mapping&gt;      
  &lt;hibernate-mapping package="example"&gt;  
      &lt;joined-subclass name="SubJoinedClass" table="SUB_JOINED_CLASS"
       extends="NiceClass"&gt;  
          &lt;key column="NICE_CLASS_ID" foreign-key="NICE_JOINED_ID_FK"/&gt;  
    &lt;property name="name" type="string" not-null="false"&gt;  
     &lt;column name="NAME" &gt;  
      &lt;comment&gt;name&lt;/comment&gt;  
     &lt;/column&gt;  
    &lt;/property&gt;  
           &lt;/joined-subclass&gt;  
  &lt;/hibernate-mapping&gt;  
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>So I want to do a:</p>
  
  <pre><code>update SubJoinedClass set name = 'newName'
  </code></pre>