1

I've method in my DAOImplwhich is intended to get a list of all books belonging to a specific user, from the database... The method looks like this:

@Override
public List<>BooksList> findListsOf(String userId) {
    Query query = em.createQuery("SELECT * from BooksList where booksListOwner = unserid");
    List<BooksList> resultsList = query.getResultList();
    if (resultsList.isEmpty()) throw new NotFoundException();
    return resultsList;
}

IntelliJ is showing me this error:

expression or DISTINCT expected, got '*'

What's wrong with my sql statement here?

BR, Mic

Mahakala108
  • 85
  • 1
  • 11

1 Answers1

1

You need to specify an identification variable rather than an SQL wilcard

List<BooksList> resultsList = em.createQuery(
  "SELECT b from BooksList b where booksListOwner = :userId")
  .setParameter("userId", userId)
  .getResultList();
Reimeus
  • 158,255
  • 15
  • 216
  • 276