title: How do I put HQL in an entity?
body: <p>I have a Hibernate entity that I would like to put a method in. This method would call the entity manager and run a prepared statement, but I don't know how to instantiate the entity manager. Whenever I try, to autowire it like so:</p>
  
  <pre><code>@Autowired
  private transient EntityManager entityManager;
  </code></pre>
  
  <p>the entityManager is null when I run the application. Autowiring works for all my other classes. Why can't I autowire the entityManager in my entity, and how do I execute my query in the Entity?</p>