30

I get a error when I createQuery:

'from' unexpected

enter image description here

My code is below:

    @Override
    public Admin findByAdmin(Admin admin) {

        return (Admin) sessionFactory.getCurrentSession().
                createQuery("from Admin where admin_name=? and pwd=?").
                setParameter(0, admin.getAdminName()).
                setParameter(1, admin.getAdminPwd()).
                uniqueResult();

    }
user7693832
  • 6,119
  • 19
  • 63
  • 114

3 Answers3

34

To fix this error in intelliJ idea

Your Project (Right-Click) ---> Framework support : check mark on "Hibernate"

Press OK.

Prashant
  • 616
  • 6
  • 10
32

I'm new to this but had the same error. What fixed things was adding the Hibernate facet under Project Structure - Facets.

0

If you can't find Hibernate in your Project Structure settings (File --> Project Structure... --> Facets) then go to File --> Settings --> Plugins and type Hibernate in search field and verify if plugin is added to Intellij. After that you will find it under Facets in your project settings and add support.

In my case this was what helped me.