title: How to create native queries in Spring?
body: <p>I have a spring application that should connect to an existing database and just query an entity for existence based on some attributes.</p>
  
  <p>I don't want to create a <code>@Entity</code> class for this. But I still want to use the spring managed <code>EntityManager</code> etc.</p>
  
  <p>When using <code>Spring</code>, what is the best approach to just query a <code>select</code> for that entity? Using <code>em.createNamedQuery(QUERY);</code> with <code>String QUERY = "SELECT count(*) from my_table where username =: username AND email := email)";</code>?</p>