将anotation添加到java类

时间:2015-06-01 10:52:13

标签: spring-mvc

此行的多个标记
- 无法将存储库解析为类型
- 注释类型

的属性值未定义

尝试将@Repository("loginDAO")添加到loginDAOImpl.java时出错。我不使用maven。

@Repository( “loginDAO”) 公共类LoginDAOImpl实现了LoginDAO {

 @Resource(name="sessionFactory")
 protected SessionFactory sessionFactory;

 public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
 }

 protected Session getSession(){
        return sessionFactory.openSession();
 }
public boolean checkLogin(String userName, String userPassword) {
    System.out.println("In Check login");
    Session session = sessionFactory.openSession();
    boolean userFound = false;
    //Query using Hibernate Query Language
    String SQL_QUERY =" from Users as o where o.userName=? and o.userPassword=?";
    Query query = session.createQuery(SQL_QUERY);
    query.setParameter(0,userName);
    query.setParameter(1,userPassword);
    List list = query.list();

    if ((list != null) && (list.size() > 0)) {
        userFound= true;
    }

    session.close();
    return userFound;
}

0 个答案:

没有答案