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/