title: Spring/Hibernate JPA NamedQuery not found
body: <p>I have a weird issue: entity manager can't create named query, I'm getting <code>java.lang.IllegalArgumentException: Named query not found</code> while methods, like <code>find()</code> and <code>merge()</code>, works. <code>createQuery()</code> also works. I'm using Hibernate as JPA provider and Spring as DI container. Code and configs are follows:<br>
  <strong>spring-beans.xml</strong>:
  <br></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
                      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                      http://www.springframework.org/schema/context
                      http://www.springframework.org/schema/context/spring-context.xsd
                      http://www.springframework.org/schema/tx
                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"&gt;
  &lt;context:component-scan base-package="org.example.testapp.database" /&gt;
  &lt;bean id="newsForm" class="org.example.testapp.presentation.form.NewsForm"&gt;
      &lt;property name="newsMessage" ref="news" /&gt;
      &lt;property name="newsList"&gt;
          &lt;list&gt;
              &lt;ref bean="news" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean name="news" class="org.example.testapp.model.News"&gt;
  &lt;/bean&gt;
  
  &lt;bean name="/news" class="org.example.testapp.presentation.action.NewsAction"
      scope="prototype"&gt;
      &lt;property name="dao" ref="dao" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dao" class="org.example.testapp.database.dao.JpaHibernateNewsDao"
      scope="singleton"&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan" value="org.example.testapp.model"/&gt;
      &lt;property name="jpaVendorAdapter" ref="jpaVendorAdapter" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jpaVendorAdapter"
      class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
      &lt;property name="database" value="ORACLE" /&gt;
      &lt;property name="showSql" value="true" /&gt;
      &lt;property name="generateDdl" value="false" /&gt;
      &lt;property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" /&gt;
      &lt;property name="url" value="jdbc:oracle:thin:@localhost:1521:xe" /&gt;
      &lt;property name="username" value="login" /&gt;
      &lt;property name="password" value="password" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;context:annotation-config/&gt;
  &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>news.java</strong></p>
  
  <pre><code> @Entity
  @NamedQueries({
      @NamedQuery(name="News.select", query="select n from News n order by news_date" ),
      @NamedQuery(name="News.delete", query="delete from News where id in :value_list")
  })
  @Table(name="news")
  public class News {
  </code></pre>
  
  <p><strong>jpadao.java</strong></p>
  
  <pre><code>public class JpaHibernateNewsDao implements Dao {
  
      @PersistenceContext
      private EntityManager entityManager;
  
      @SuppressWarnings("unchecked")
      @Override
      @Transactional
      public List&lt;News&gt; getList() throws DaoException {
          List&lt;News&gt; news = entityManager.createNamedQuery("News.select").getResultList();
          return news;
      }
  </code></pre>