java - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : Unknown column 'email' in 'where clause'

标签 java mysql spring hibernate

String hql="from "+ Employee.class.getName()
                  + " where email= ? and password=? ";
List<Employee> emplist=ht.find(hql,email,pwd);

这是我遇到的错误,你能帮我解决吗?

Hibernate: 
    select
        employee0_.empid as empid0_,
        employee0_.empmail as empmail0_,
        employee0_.empmobile as empmobile0_,
        employee0_.empname as empname0_,
        employee0_.emppassword as emppassw5_0_ 
    from
        emptab employee0_ 
    where
        email=? 
        and employee0_.emppassword=?

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown
column 'email' in 'where clause'

带有表名 emptab 的格式化 Employee 代码如下:

@Entity 
@Table(name="emptab") 
public class Employee { 
  @Id
  @Column(name="empid") 
  private int id; 

  @Column(name="empname") 
  private String name; 

  @Column(name="emppassword") 
  private String password; 

  @Column(name="empmail") 
  private String mail; 

  @Column(name="empmobile") 
  private int mobile
  }

最佳答案

您的查询应类似于:

String hql="from "+ Employee.class.getName()
                  + " e where e.mail= ? and e.password=? ";

确保电子邮件和密码字段已存在于数据库中的员工实体和员工表中。

关于java - com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : Unknown column 'email' in 'where clause' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49548208/

相关文章:

java - WebView 中的 "android.view.InflateException: Binary XML file Error inflating class"错误

java - 使用keytool安装安全证书

mysql - 面向用户的 SQL 管理框架(针对非专家用户)

mysql - 获取一列与另一列匹配的结果

mysql 计数 group_concat 中的项目

java - 使用hibernate向数据库插入数据

java - 将动态字段添加到 Spring JSON View 响应

java - 在 Spring 中为 RestTemplate 客户端抛出 ResourceAccessException vs HttpClientErrorException

java - Web 应用程序创建了一个 ThreadLocal,但未能将其删除 Tomcat [SEVERE]

java - 将 GWT 模块作为 JavaScript 分发