我需要帮助,我遇到了上述异常。我哪里错了?在从类到表的映射中,我使用了以下内容:
private String userId;
private String password;
下面是我编写查询的课程。
public class LoginManager extends HibernateUtil {
private String loginId;
public String checkCredentials(String userId, String password) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
try {
loginId = (String) session.createQuery("select user_id from com.project.model.Login where user_id=:userId and password=:password")
.setParameter("userId",userId)
.setParameter("password", password)
.list().toString();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
}
session.getTransaction().commit();
return loginId;
}
}
实体
@Entity
@Table(name = "Login")
public class Login implements Serializable {
private static final long serialVersionUID = 2L;
private String userId;
private String password;
@Id
@Column(name = "user_id")
public String getUserId() {
return userId;
}
public void setUser_id(String userId) {
this.userId = userId;
}
@Column(name = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}