M
M
Maks Burkov2017-02-27 01:45:54
Hibernate
Maks Burkov, 2017-02-27 01:45:54

HQL Hibernate how to write correctly?

Hello! Who is familiar with HQL in hibernet? How to write this question correctly? Rolled from a book but it's not clear why it doesn't work?
Error:
"Can't resolve symbol persons" "Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException
: persons is not mapped [from persons p where p.name = :name ]""
IDEA, there are settings for Facets under hibernate!Despite this, I get compilation errors!

public static Person findPerson(Session session , String name){
        String makeQuery = "from persons p where p.name = :name "; // Тут выдаёт ошибку компиляции на persons! Почему ? 
        Query query = session.createQuery(makeQuery);
        query.setParameter("name",name);
        return (Person) query.uniqueResult();
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-02-27
@Maks00088

Entity name, capitalized and singular, exactly as the class is named: "from P erson ̶s̶ p where p.name = :name"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question