Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:3.2 ga
Mapping documents:
Code:
<class name="com.UnifiedPersonRecordUpdate" table="tbl_person_update">
<id name="updateID" column="id">
<generator class="native" />
</id>
<property name="personId" column="person_id" />
<property name="p1" column="name_P1" />
</class>
Code between sessionFactory.openSession() and session.close():
Code:
org.hibernate.Session session;
session=HibernateUtil.getSession();
org.hibernate.Transaction tx = session.beginTransaction();
String hqlUpdate = "UPDATE UnifiedPersonRecordUpdate person set person.p1 = :newName where person.personId = :PersonID";
// or [color=red]String hqlUpdate = "update Customer set name = :newName where name = :oldName";[/color] int updatedEntities = session.createQuery( hqlUpdate )
.setString( "newName", p1 )
.setLong("personId", personId )
.executeUpdate();
tx.commit();
session.close();
Full stack trace of any exception that occurs:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: #{backing_search3.Update}: javax.faces.el.EvaluationException: org.hibernate.QueryException: query must begin with SELECT or FROM: UPDATE [UPDATE com.etelic.UnifiedPersonRecordUpdate person set person.p1 = :newName where person.personId = :PersonID]
javax.faces.webapp.FacesServlet.service(FacesServlet.java:225)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
root cause
javax.faces.FacesException: #{backing_search3.Update}: javax.faces.el.EvaluationException: org.hibernate.QueryException: query must begin with SELECT or FROM: UPDATE [UPDATE com.etelic.UnifiedPersonRecordUpdate person set person.p1 = :newName where person.personId = :PersonID]
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:98)
javax.faces.component.UICommand.broadcast(UICommand.java:332)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
root cause
javax.faces.el.EvaluationException: org.hibernate.QueryException: query must begin with SELECT or FROM: UPDATE [UPDATE com.etelic.UnifiedPersonRecordUpdate person set person.p1 = :newName where person.personId = :PersonID]
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:150)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
javax.faces.component.UICommand.broadcast(UICommand.java:332)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
root cause
org.hibernate.QueryException: query must begin with SELECT or FROM: UPDATE [UPDATE com.etelic.UnifiedPersonRecordUpdate person set person.p1 = :newName where person.personId = :PersonID]
org.hibernate.hql.classic.ClauseParser.token(ClauseParser.java:83)
org.hibernate.hql.classic.PreprocessingParser.token(PreprocessingParser.java:108)
org.hibernate.hql.classic.ParserHelper.parse(ParserHelper.java:28)
org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:216)
org.hibernate.hql.classic.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:185)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
com.etelic.dao.PersonAddProfileDAOHibernate.updatePeopleRecords(PersonAddProfileDAOHibernate.java:88)
com.etelic.bo.PersonAddBO.updatePeopleByParameters(PersonAddBO.java:28)
com.etelic.manager.PersonAddManager.UpdatePeopleByParameters(PersonAddManager.java:17)
com.etelic.controller.PersonAddProfileInput.Update(PersonAddProfileInput.java:259)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
javax.faces.component.UICommand.broadcast(UICommand.java:332)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.14
Name and version of the database you are using:
MYSQL 5
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with HQL.
Read this:
http://hibernate.org/42.html