修改报无主键
wdxff 发布于32月前 2答/723阅

我的原始需求是:修改


实现过程中遇到的问题:

com.jfinal.plugin.activerecord.ActiveRecordException: You can't update model without Primary Key, id can not be null.

at com.jfinal.plugin.activerecord.Model.update(Model.java:607)

at com.yysl.emp.EmpController.updatePassword(EmpController.java:26)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.jfinal.aop.Invocation.invoke(Invocation.java:73)

at com.eova.interceptor.AuthInterceptor.intercept(AuthInterceptor.java:49)

at com.jfinal.aop.Invocation.invoke(Invocation.java:67)

at com.eova.interceptor.LoginInterceptor.intercept(LoginInterceptor.java:69)

at com.jfinal.aop.Invocation.invoke(Invocation.java:67)

at com.jfinal.core.ActionHandler.handle(ActionHandler.java:78)

at com.eova.handler.UrlBanHandler.handle(UrlBanHandler.java:38)

at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:81)

at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)

at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)

at org.eclipse.jetty.server.Server.handle(Server.java:365)

at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)

at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)

at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)

at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)

at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)

at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)

at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)

at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)

at java.lang.Thread.run(Thread.java:745)




我觉得这个问题的原因是:



[沙发] Jieven
@wdxff 通过 at com.yysl.emp.EmpController.updatePassword(EmpController.java:26) 可以判定,这是一个自定义功能,自定义功能的SQL是你自己控制的,
报错:com.jfinal.plugin.activerecord.ActiveRecordException: You can't update model without Primary Key, id can not be null.
意思是说 你要 xxx.update() 必须保证 xxx 这个对象有主键,否则你咋更新,请自查
update xxx set password = ? where id = ? 显然需要2个参数才能执行sql,请自查!
提交评论
嘿,我来帮你!