[quote="adil"]Hi,
I have been trying to delete a few records from the database using the following named query :
[b]<sql-query name="Delete_Express">
DELETE SEC_LOG WHERE TIME between convert(smalldatetime, ? ) and convert(smalldatetime, ? )
</sql-query> [/b]
Now to call this query, i use [b]query.executeUpdate();[/b], but I get an exception :
[b]java.lang.UnsupportedOperationException: Update queries only supported through HQL
org.hibernate.impl.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:607)[/b].
Could anyone tell me how to call such a query from hibernate? Any help is appreciated.[/quote]
Yo have to specifc parameters names in you sql-query code, like this:
DELETE SEC_LOG WHERE TIME between convert(smalldatetime, :param1 ) and convert(smalldatetime, :param2 )
Then, you have to set parameters values in your hibernate code:
Query q = session.getNameQuery("Delete_Express");
q.setParameter("param1", object1);
q.setParameter("param2", object2);
I guess that will help you to solve your problem.
Requests for comments
|