我正在使用hibernate和WAS中的数据库(Websphere Application Server [IBM]),我有时会收到此错误:
java.lang.ArrayIndexOutOfBoundsException
at com.ibm.ws.rsadapter.spi.CacheMap.removeLRU(CacheMap.java:378)
at com.ibm.ws.rsadapter.spi.CacheMap.add(CacheMap.java:180)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.cacheStatement(WSRdbManagedConnectionImpl.java:3150)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.closeWrapper(WSJdbcPreparedStatement.java:513)
at com.ibm.ws.rsadapter.jdbc.WSJccPreparedStatement.closeWrapper(WSJccPreparedStatement.java:290)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:241)
at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:194)
at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:563)
at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:214)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1300)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:365)
是多线程应用程序,因此在执行多个访问时可能会出现与hibernate缓存相关的一些内容,但我不确定。执行hibernate查询语句时会抛出错误,如
query.list();
或
query.executeUpdate();
我试图将cacheable设置为false,将CacheMode设置为IGNORE:
Session session = getSession();
session.setCacheMode(CacheMode.IGNORE);
session.createSQLQuery('query').setCacheable(false);
用于禁用缓存,但正如我所说,有时会出现异常。
我的hibernate-config.xml就是这个:
<hibernate-configuration>
<session-factory name="HibernateSessionFactory">
<property name="hibernate.dialect">${hibernate.dialect}</property>
<property name="hibernate.show_sql">${hibernate.show_sql}</property>
<property name="hibernate.format_sql">${hibernate.format_sql}</property>
<property name="hibernate.use_sql_comments">${hibernate.use_sql_comments}</property>
<property name="hibernate.connection.autocommit">true</property>
<property name="hibernate.connection.aggressive_release">false</property>
<property name="hibernate.connection.release_mode">after_transaction</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
<property name="hibernate.connection.pool_size">0</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.transaction.auto_close_session">true</property>
<property name="hibernate.transaction.flush_before_completion">true</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
</session-factory>
</hibernate-configuration>
在这里你可以看到我一直试图完全禁用缓存,但它仍然无法正常工作。
任何帮助或建议都将不胜感激。
非常感谢您提前! :d