我是hibernate的新手。在HQL查询中发送静态参数时,其工作正常。在setParameter方法中发送时,它会给出空指针异常。请帮助我做错了。
/** HQL Query **/
String hql = "FROM MUser mUser where mUser.uEmail = :email AND mUser.uPassword = :password";
Query query = getCurrentSession().createQuery(hql);
query.setParameter("email", "xyz@fsndk.com");
query.setParameter("password", "12345678");
MUser muser = (MUser) query.uniqueResult();
模型类
/** Mapping Class **/
@Entity
@Table(name="tbl_users")
public class MUser implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
int uId;
String uName;
String uMobile;
String uAddress;
String uEmail;
String uPassword;
...
}
错误发生
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)