Hi,

I am using hibernate 4 my application.. when i am using "named sql query" 4 update or insert statements, it is throwing following error

java.lang.UnsupportedOperationException: Update queries only supported through HQL

i am using following tag in hbm file for named query


<class name="com.user.User" table="USR">
<id name="userId" type="java.lang.String" column="USR_ID" >
<generator class="assigned"/>
</id>

<property name="lastName">
<column name="USR_LAST_NM"/>
</property>

</class>

<sql-query name="myInsertQuery">update User usr set usr.lastName=? where usr.userId=?</sql-query>


here User is my class

Following is the code 4 executing named query

SQLQuery query = (SQLQuery) session.getNamedQuery("myUpdateQuery");
query.setParameter(0, "K");
query.setParameter(1, "NEHA");
query.executeUpate();



Please help

Thanks
Neha