我使用Hibernate实现了Spring Security,但它没有用。我收到了这个错误:
org.hibernate.hql.ast.QuerySyntaxException: Uzivatel is not mapped [from Uzivatel u where u.username = :username]
org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
...
哪里可能出错?
我的UzivatelDaoImpl.class
@Repository
public class UzivatelDaoImpl implements UzivatelDao{
@Autowired
private SessionFactory session;
private Session openSession() {
return session.getCurrentSession();
}
@SuppressWarnings("unchecked")
@Override
public Uzivatel getUzivatel(String username) {
List<Uzivatel> uzivatelList = new ArrayList<Uzivatel>();
Query query = openSession().createQuery("from Uzivatel u where u.username = :username");
query.setParameter("username", username);
uzivatelList = query.list();
if (uzivatelList.size() > 0)
return (Uzivatel) uzivatelList.get(0);
else
return null;
}
}
答案 0 :(得分:1)
可能你没有在hibernate.cfg.xml中映射实体,或者在Uzivatel类中没有@Entity注释。