title: Why do backslashes need to be escaped in JPA native queries?
body: <p>In JPA, when executing a native query, I have to escape backslash characters to double backslash. E.g. when having a where clause like</p>
  
  <pre><code>UPPER(app.NAME) like UPPER(?) escape '\'
  </code></pre>
  
  <p>then I need to create a string which contains:</p>
  
  <pre><code>UPPER(app.NAME) like UPPER(?) escape '\\'
  </code></pre>
  
  <p>Then I run a native query using openJPA 2.2.2:</p>
  
  <pre><code>final EntityManager entityManager = EntityManagerFinder.getEntityManager();
  final Query query = entityManager.createNativeQuery(sql, Response.class);
  </code></pre>
  
  <p>The SQL statement is read from XML file, hence Java escaping is not done here. Furthermore I verified during debugging that the String in Java is really the same as in the XML file.</p>
  
  <p>Why is JPA expecting double backslash for native queries? Is this a bug in openJPA?</p>