来自getCurrentSession的NullPointerException

时间:2014-03-27 22:28:24

标签: java spring hibernate hsqldb

我从@Transactional注释方法中的一个简单的getCurrentSession()调用得到NullPointerException。这是堆栈跟踪。我甚至没有配置任何缓存时,我无法弄清楚为什么cacheProvider为null。

有没有人遇到过类似的问题?我搜索了论坛,但大多数问题都没有得到解答。

Hibernate:3.3

HypersonicSQL:2.2

这是单线程Junit测试。

SessionFactory配置

  <bean id="SessionFactoryAbstractParent" abstract="true">
    <property name="mappingResources">Skipped</property>

    <datasource configuration skipped ... />

    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
        hibernate.show_sql=true
        hibernate.format_sql=true
        hibernate.max_fetch_depth=1
        hibernate.cache.use_second_level_cache=true
        hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
        hibernate.jdbc.batch_size=50
        hibernate.order_inserts=true
        hibernate.order_updates=true
        hibernate.use_sql_comments=true
        hibernate.connection.oracle.jdbc.ReadTimeout=300000
      </value>
    </property>
  </bean>


  <bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" parent="SessionFactoryAbstractParent">
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.HSQLDialect
        hibernate.show_sql=false
        hibernate.format_sql=true
        hibernate.hbm2ddl.auto=create-drop
        hibernate.max_fetch_depth=1
    hibernate.cache.region.factory_class=org.hibernate.cache.HashtableCacheProvider
      </value>
    </property>
  </bean>
  

显示java.lang.NullPointerException           在org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)           在org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:526)           在org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:535)           在org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:323)           在org.springframework.orm.hibernate3.SessionFactoryUtils.doGetSession(SessionFactoryUtils.java:258)           在org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:60)           在org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)

0 个答案:

没有答案