Hibernate305: delete query fails with "must begin with SELECT or FROM"



(I posted this first to c.l.j.p, but I realized it's more appropriate
here.)

I'm following the Hibernate 3.0.5 docs to build a query to delete rows
from a table. My code looks something like this:

-----------------
String hql = "delete ReqField " +
"where fieldName = :fieldName and value
= :value";
Query query =
sessionFactory.getCurrentSession().createQuery(hql);
query.setString("fieldName", fieldName);
query.setString("value", value);

int deletedRows = query.executeUpdate();
-----------------

This fails with:

org.hibernate.QueryException: query must begin with SELECT or FROM:
delete [delete ReqField where fieldName = :fieldName and value
= :value]

What is wrong with my query?

I also tried changing "delete ReqField" to "delete from ReqField", but
that still gets the same error message (with "delete from" in the
message).

.



Relevant Pages

  • Re: Importing Text File that is vertically oriented
    ... the Value corresponding to any FieldName. ... Create a query on the table that returns both fields and a dummy ... >I would ideally like to setup a linked table to import this data - does ... John Nurick [Microsoft Access MVP] ...
    (microsoft.public.access.externaldata)
  • Re: Why does this Nested IIF statement add AS fields
    ... when you create a calculated field in the query design screen, Access assigns an 'alias' to the new fieldname. ... It is a good idea, however, to make the calculated fieldname different than any fieldname in the source tables so Access does not get confused. ... I am using ACCESS 2003 and the query type is "make table". ... OPENING_BALANCE AS [P3Overall Balance] INTO Phase3Data ...
    (microsoft.public.access.queries)
  • Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
    ... I'm following the Hibernate 3.0.5 docs to build a query to delete rows ... "where fieldName =:fieldName and value ... that still gets the same error message (with "delete from" in the ...
    (comp.lang.java.databases)
  • Re: The like clause of sql
    ... Are you using a form to enter a value and you want to build a query string ... > Its not that simple because Tablename.FieldName is a fieldname ... > but then i get Syntax error in query expression '(%email% LIKE ... >> SELECT Tablename.* ...
    (microsoft.public.access.queries)
  • Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
    ... "where fieldName =:fieldName and value ... Query query = ... that still gets the same error message (with "delete from" in the ... I guess you should not use a query object for an update, ...
    (comp.lang.java.databases)