您的位置:首页 > 产品设计 > UI/UE

org.hibernate.HibernateException: Errors in named queries问题

2017-02-15 10:08 567 查看
org.hibernate.HibernateException: Errors in named queries问题解决方案:

1、从hibernate版本升级入手

2、配置的org.springframework.orm.hibernate3.LocalSessionFactoryBean中的hibernateProperties入手:

<property name="hibernateProperties">
<props>
<!--
<prop key="hibernate.hbm2ddl.auto">update</prop>
-->
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.provider">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
<prop key="hibernate.connection.setBigStringTryClob">true</prop>
<prop key="connection.autoReconnect">true</prop>
<prop key="connection.autoReconnectForPools">true</prop>
<prop key="connection.is-connection-validation-required">true</prop>
<!--
<prop key="hibernate.hbm2ddl.auto">validate | update | create | create-drop</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
<prop key="hibernate.jdbc.batch_size">50</prop>
<prop key="hibernate.jdbc.fetch_Size">100</prop>
-->
</props>
</property>
3、从mappingLocations入手:

<property name="mappingLocations">
<list>
<value>classpath*:/com/businessmatrix/**/entity/dbo/*.hbm.xml</value>
<value>classpath*:/com/businessmatrix/auth/entity/dbo/nameQuery/NQ-auth.xml</value>
</list>
</property>
总的配置:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="lobHandler" ref="oracleLobHandle"/>
<property name="dataSource" ref="dataSource" />
<!-- <property name="mappingDirectoryLocations">-->
<!-- <property name="mappingLocations">
<list>
<value>classpath*:/com/businessmatrix/**/entity/dbo/*.hbm.xml</value>
</list>
</property>
<property name="mappingResources">
<list>
<value>com/businessmatrix/auth/entity/dbo/nameQuery/NQ-auth.xml</value>
</list>
</property> -->
<property name="mappingLocations"> <list> <value>classpath*:/com/businessmatrix/**/entity/dbo/*.hbm.xml</value> <value>classpath*:/com/businessmatrix/auth/entity/dbo/nameQuery/NQ-auth.xml</value> </list> </property>
<!-- <property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/ips-auth20160309.jar</value>
</list>
</property> -->
<property name="hibernateProperties"> <props> <!-- <prop key="hibernate.hbm2ddl.auto">update</prop> --> <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop> <prop key="hibernate.cache.provider">org.hibernate.cache.EhCacheProvider</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop> <prop key="hibernate.connection.setBigStringTryClob">true</prop> <prop key="connection.autoReconnect">true</prop> <prop key="connection.autoReconnectForPools">true</prop> <prop key="connection.is-connection-validation-required">true</prop> <!-- <prop key="hibernate.hbm2ddl.auto">validate | update | create | create-drop</prop> <prop key="hibernate.dialect">org.hibernate.dialect.DerbyDialect</prop> <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop> <prop key="hibernate.jdbc.batch_size">50</prop> <prop key="hibernate.jdbc.fetch_Size">100</prop> --> </props> </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<tx:annotation-driven transaction-manager="transactionManager" />
<!--
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
-->

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐