title: unexpected token: LIMIT
body: <p><strong>I am getting an error mention in ERROR section when using the mentioned dependency with NamedQuery.</strong></p>
  
  <p>Note: please suggest, is it a jar problem or JBOSS? I am running this code in Jboss 7 version with jdk1.7.</p>
  
  <p><strong>Named query used using EntityManager:</strong></p>
  
  <pre><code>Query query = this.entityManager.createNamedQuery("Program.findAll");// it will give only one Program limited to 1
          List&lt;Program&gt; programs = query.getResultList();
      @Entity
      @Table(name="PROGRAM")
      @NamedQueries({@NamedQuery(name="Program.findAll", query="SELECT p FROM Program p LIMIT 2")
      })
  </code></pre>
  
  <p><strong>below code is from POM.xml</strong></p>
  
  <pre><code>&lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
     &lt;version&gt;4.2.7.Final&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
     &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
     &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
     &lt;version&gt;4.2.7.Final&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax&lt;/groupId&gt;
      &lt;artifactId&gt;javaee-api&lt;/artifactId&gt;
      &lt;version&gt;6.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
      &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
      &lt;version&gt;1.0.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>18:27:44,447 INFO  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-5) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
  18:27:44,748 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-5) HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
  18:27:44,764 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-5) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
  18:27:44,764 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-5) HHH000397: Using ASTQueryTranslatorFactory
  18:27:44,826 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-5) Hibernate Validator 4.2.0.Final
  18:28:02,721 ERROR [org.hibernate.hql.internal.ast.ErrorCounter] (MSC service thread 1-5) line 1:50: unexpected token: LIMIT
  18:28:02,727 ERROR [org.hibernate.hql.internal.ast.ErrorCounter] (MSC service thread 1-5) line 1:50: unexpected token: LIMIT: line 1:50: unexpected token: LIMIT
      at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClassOrOuterQueryPath(HqlBaseParser.java:1866) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.fromRange(HqlBaseParser.java:1492) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.fromClause(HqlBaseParser.java:1336) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1054) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:700) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:294) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:157) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:180) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:101) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.engine.query.spi.HQLQueryPlan.&lt;init&gt;(HQLQueryPlan.java:80) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:974) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:485) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.ejb.EntityManagerFactoryImpl.&lt;init&gt;(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
      at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]
      at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]
  </code></pre>