1

I'm trying to get objects from database using hibernate class. but it cannot find mehod ".list()" it says "Javadoc not found". I don't know how to use this method.

List users= session.createQuery("FROM User WHERE Email=:email AND Password=:password")
            .setParameter("password", password)
            .setParameter("email", email).list();
Tannaz Shirzadi
  • 81
  • 1
  • 2
  • 4
  • "*`List users`*" - [Don't use raw types](https://stackoverflow.com/questions/2770321/what-is-a-raw-type-and-why-shouldnt-we-use-it). Alongside with this change, type the query: `session.createQuery("FROM User WHERE Email=:email AND Password=:password", User.class)` --- Use `.getResultList()`, not `list()`. – Turing85 Jan 10 '20 at 16:23
  • It doesn't have that method, I think the problem is how to add its library – Tannaz Shirzadi Jan 10 '20 at 16:48
  • @Turing85 `.getResultList()` exists in `javax.persistence.Query` class, not in `org.hibernate.Query`. `javax.persistence.EntityManager` creates `javax.persistence.Query` and `org.hibernate.Session` creates `org.hibernate.Query` – meiskalt7 Feb 12 '20 at 04:02

2 Answers2

0

1) check that createQuery() method returns object of org.hibernate.Query class

in all versions of the Hibernate method .list() exists:

old Javadoc https://docs.jboss.org/hibernate/orm/3.2/api/org/hibernate/Query.html#list()

new Javadoc https://docs.jboss.org/hibernate/orm/5.4/javadocs/org/hibernate/query/Query.html

2) List users - never use raw types, because collections with a type(List<User>) gives you compile-time type checking, thus prevents errors in runtime-time.

meiskalt7
  • 606
  • 7
  • 13
0

The displaying of "Javadoc not found" from Editor mean it cannot find documentation for class/method. It doesn't prevent compile/running code.

Just ignore that message and try to compile/run the code.

Kevin Le
  • 266
  • 1
  • 5