EntityManager injected with @PersistenceContext throwing NullPointerException on createQuery()

I opened this issue in spring-data-jpa repository but they redirected me to here.
The problem is highly detailed in https://github.com/spring-projects/spring-data-jpa/issues/2304.

Your query is wrong. You are trying to “select” an entity name which doesn’t make sense. You can only refer to nodes in the FROM clause through an alias. So use this instead: SELECT s from Schedule s ORDER BY scheduledAt DESC