package com.javen.model;
import java.util.List;
import java.util.Map;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.ehcache.CacheKit;
import com.jfinal.plugin.ehcache.IDataLoader;
/**
* 授权获取到的用户信息
* @author Javen
*/
public class Student extends Model<Student> {
private static final long serialVersionUID = 6204222383226990020L;
static Log log = Log.getLog(Student.class);
public static final Student dao = new Student();
public List<Student> getAll(){
return dao.find("select * from Student");
}
/**
* 所有 sql 与业务逻辑写在 Model 或 Service 中,不要写在 Controller 中,养成好习惯,有利于大型项目的开发与维护
*/
public Page<Student> paginate(int pageNumber, int pageSize) {
return paginate(pageNumber, pageSize, "select *", "from Student order by id asc");
}
public Student findByStudentName(String studentName){
return this.findFirst("select * from student where studentname=?", studentName);
}
public Student findByStudentCode(String studentCode){
return this.findFirst("select * from student where studentcode=?", studentCode);
}
public Student findByPersonCode(String personCode){
return this.findFirst("select * from student where personcode=?", personCode);
}
/**
* 根据map参数查找
* @param paras
* @return
*/
public List<Student> findByMap(Map<String, Object> paras) {
StringBuilder sql = new StringBuilder("select * from Student ");
if (paras.containsKey("order")) {
sql.append(" ORDER BY ");
sql.append(paras.get("order"));
sql.append(" ");
}
if (paras.containsKey("limit")) {
sql.append(" LIMIT ");
sql.append(paras.get("limit"));
}
return this.findByCache("tenMinute", "Student", sql.toString());
}
}
以下是异常信息
[ERROR]-[Thread: qtp1105085593-25]-[com.jfinal.core.ActionHandler.handle()]: /ajax/bindingStudent
java.lang.NullPointerException
at com.jfinal.plugin.activerecord.Model.find(Model.java:583)
at com.jfinal.plugin.activerecord.Model.findFirst(Model.java:601)
at com.javen.model.Student.findByStudentCode(Student.java:43)
at com.javen.controller.AjaxController.bindingStudent(AjaxController.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
at com.jfinal.validate.Validator.intercept(Validator.java:86)
at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:74)
at com.jfinal.plugin.druid.DruidStatViewHandler.handle(DruidStatViewHandler.java:75)
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.content(AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
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)
student.class 我是直接复制的TUser.java,
麻烦问下各位大神,这个问题怎么解决啊??