从错误看FOR   UPDATE 子句仅允许用于   DECLARE   CURSOR这个只允许在存储过程里面使用。

解决方案 »

  1.   

    应该还是数据库方言设置的问题,我把实体的ID标注改为IDENTITY后,出现的是下面的错误
    43578 [http-8088-Processor24] ERROR org.hibernate.util.JDBCExceptionReporter  - 第 1 行: 'limit' 附近有语法错误。
    43609 [http-8088-Processor24] ERROR com.easyjf.web.core.DefaultRequestProcessor  - 出现错误:org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)
    at com.easyjf.core.dao.impl.GenericDAOImpl$1.doInJpa(GenericDAOImpl.java:79)
    at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:192)
    at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:157)
    limit是MYSQL的语法了,显然的我数据库言设置没有作用
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
     <persistence-unit name="ejs-app-unit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
    <property name="hibernate.show_sql" value="true" />
    <property name="hibernate.hbm2ddl.auto" value="update" />
    <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" />
    <property name="hibernate.cache.use_query_cache" value="false" />
    </properties>
    </persistence-unit>
    </persistence>
      

  2.   

    问题解决,原来是COPY过来的配置文件里多了一个画蛇添足的配置
    <bean name="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation"
    value="classpath:persistence.xml" />
    <property name="dataSource" ref="dataSource" />
    <property name="jpaVendorAdapter">
    <bean
    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <!-- <property name="database" value="MYSQL" /> -->
    <property name="showSql" value="false" />
    <property name="generateDdl" value="false" />
    </bean> </property>
    </bean>
    就是上面被我注释掉的部分啦,散分了