title: How to change JPA 2.0 SQL/JPQL queries dynamically in production
body: <p>I have a problem with the architecture of JPA 2.0/ORM,
  in our production system (and i believe in a lot of systems) we need the ability to change the SQL queries dynamically because slow queries and bugs in queries that was exposed only in production (heavy load and heavy data),
  as a result we used in stored procedures and call them from iBatis.</p>
  
  <p>As i see the pattern, the best practice is to seperate between the DB layer and the application layer so i can tell to my DBA to fix buggy stored procedures/indexes tables in production without deployed new application (distribute system - long time of deployment).</p>
  
  <p>In ORM/JPA 2.0 the named queries defined in the code and it's cause to the programmer to catch the whole DB problems in development/QA - very bad!</p>
  
  <p>I saw in the API that the framework give an option to define native query - but in the books/tutorials the best practice is to use the named queries...</p>
  
  <p>After i read the Hibernate/JPA 2.0 SPEC to see if there is a solution for this problem,
  i understand that there is no solution...?</p>
  
  <p>Its look to me very wired that i need to define the queries hard coded in the application code layer... 
  also to define the queries in XML descriptor and to load the XML via patch solution of hot deploy - very bad and not as standard!</p>
  
  <p>Did you have design pattern/solution</p>
  
  <p>Thank you all!!!</p>
  
  <p>Uri.</p>