Hibernate305: delete query fails with "must begin with SELECT or FROM"
- From: "david.karr" <davidmichaelkarr@xxxxxxxxx>
- Date: 26 Mar 2007 16:01:05 -0700
(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).
.
- Follow-Ups:
- Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
- From: joeNOSPAM@xxxxxxx
- Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
- Prev by Date: Hibernate: Changing load() behavior (proxy/full object) at runtime?
- Next by Date: Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
- Previous by thread: Hibernate: Changing load() behavior (proxy/full object) at runtime?
- Next by thread: Re: Hibernate305: delete query fails with "must begin with SELECT or FROM"
- Index(es):
Relevant Pages
|
|