Hibernate 的关键字lock

今天在编代码时碰到一个问题:
JDBCExceptionReporter.logExceptions(72) | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lock='0', content='1' where id=1' at line 1
[BJXD] ERROR [http-8080-Processor22] AbstractFlushingEventListener.performExecutions(277) | Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
 at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
 at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
 at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:394)
 at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
 at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:642)
 at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:638)
 at com.onexun.zgxq.dao.admin.OrgInfoDaoIMP.editOrgInfo(OrgInfoDaoIMP.java:32)
 at com.onexun.zgxq.action.admin.OrgInfoAction.del(OrgInfoAction.java:78)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:300)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:166)
 at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
 at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
 at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
 at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:272)
 at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:237)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lock='0', content='1' where id=1' at line 1
 at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:891)
 at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
 at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
 ... 39 more
org.springframework.jdbc.BadSqlGrammarException: Hibernate operation: Could not execute JDBC batch update; bad SQL grammar [update org_info set user_id=?, city_id=?, univercity_id=?, spoken_id=?, org_type=?, name=?, type=?, city_name=?, univercity_name=?, user_name=?, spoken_name=?, spoken_pic=?, join_right=?, member_num=?, score=?, level=?, adversite=?, intro=?, keyword=?, found_time=?, lock=?, content=? where id=?]; nested exception is java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lock='0', content='1' where id=1' at line 1
Caused by: java.sql.BatchUpdateException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lock='0', content='1' where id=1' at line 1
 at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:891)
 at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
 at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
 at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
 at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
 at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
 at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
 at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
 at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:394)
 at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
 at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:642)
 at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:638)
 at com.onexun.zgxq.dao.admin.OrgInfoDaoIMP.editOrgInfo(OrgInfoDaoIMP.java:32)
 at com.onexun.zgxq.action.admin.OrgInfoAction.del(OrgInfoAction.java:78)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:300)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:166)
 at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
 at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
 at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:164)
 at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
 at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:272)
 at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:237)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
 at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
 at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
 at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
 at java.lang.Thread.run(Thread.java:595)
 
原因: lock 是Hibernate的关键字 不允许使用
解决方法:  修改字段的名字
 

你可能感兴趣的:(hibernate,server,mysql,sql,jdbc,exception)