2010-04-20 21:57:38read-only cache configured for mutable class: entity.Classes
2010-04-20 21:57:38Could not find configuration [entity.Classes]; using defaults.
测试过程中出现如上两条信息,但测试结果是正确的。我是边看教学视频边敲代码的,视频上没出现这个问题,我倒出现了,自己搞半天也不知道问题出在哪。
如果说这个 entity.Classes 没找到,那为什么结果会正确呢,我专门改成 entity.Classessss 一运行就直接报错了,说明entity.Classes 这个还是对的。希望有人看懂这个这个问题的能告诉我下,谢谢。

解决方案 »

  1.   

    2010-04-20 21:57:38read-only cache configured for mutable class: entity.Classes
    把hbm.xml里的<cache>改成read-write,就像这样:<cache usage="read-write" />
      

  2.   

    只是提示你没有找到entity.Classes的配置,启用默认配置,并没有说entity.Classes没有找到
      

  3.   


    能不在映射文件里改代码吗?
    我是在hibernate.cfg.xml文件中添加下面的标签来让我的实体能保存到二级缓存中的。
    <class-cache usage="read-only" class="entity.Classes"/>
      

  4.   

    那就把这个改成
    <class-cache usage="read-write" class="entity.Classes"/>
      

  5.   


    加上去只少了第一条提示信息
    另一条还是出来了
    2010-04-20 22:25:09Could not find configuration [entity.Classes]; using defaults.而且我要的就是 usage="read-only"只读 这样不可以吗?
    还有为什么改成usage="read-write"第一条提示信息就不会出来呢?
      

  6.   

    查了一下hibernate代码,第二条提示是EhCache打出来的,可以无视,当然如果你去配也可以,去ehcache.xml里配这个类的缓存吧
      

  7.   

    第一个提示意思是你缓存配的是只读,但你这个类是可变类(相反于immutable class),所以警告你不安全,只是警告,也可以无视
      

  8.   

    站同3楼  java程序员群 108363309(欢迎加入)
      

  9.   

    引用justlearn: 只是提示你没有找到entity.Classes的配置,启用默认配置,并没有说entity.Classes没有找到我加了 个 CACHE 监听器: <cacheManagerEventListenerFactory class="org.jdit.cache.secondary.ehcache.listener.EhcacheManagerEventListenerFactory"/>源代码org.jdit.cache.secondary.ehcache.listener.EhcacheManagerEventListenerFactory如下:public class EhcacheManagerEventListenerFactory 
    extends CacheManagerEventListenerFactory { @Override
    public CacheManagerEventListener createCacheManagerEventListener(
    Properties arg0) {
    return new EhcacheManagerEventListener();
    }}
    class EhcacheManagerEventListener implements CacheManagerEventListener { public void notifyCacheAdded(String cacheName) {
    System.out.println("Cache [" + cacheName + "] Added");
    } public void notifyCacheRemoved(String cacheName) {
    System.out.println("Cache [" + cacheName + "] Deleted");
    }

    }最后日志中报:
    WARN - Could not find configuration [com.dp.jdit.community.Issue]; using defaults.
    Cache [com.dp.jdit.community.Issue] Added
    从日记第一行中看出"没有找到entity.Classes的配置,启用默认配置", 
    但日记中第二行打印出: Cache [com.dp.jdit.community.Issue] Added, 说明会创建一个com.dp.jdit.community.Issue缓存........怪不???????????????怪不???????????????怪不???????????????怪不???????????????怪不???????????????怪不???????????????
      

  10.   

    楼主, 关于你日记中的第一条信息: 2010-04-20 21:57:38read-only cache configured for mutable class: entity.Classes, 你需要在你的MAPPING中配置: 
    <class ... mutable="false" ...>官方文档说明: 
    19.2.2. Strategy: read onlyIf your application needs to read but never modify instances of a persistent class, a read-only cache may be used. This is the simplest and best performing strategy. It's even perfectly safe for use in a cluster.<class name="eg.Immutable" mutable="false">
         <cache usage="read-only"/>
         ....
    </class>中文解释: 
    19.2.2. 策略:只读缓存(Strategy: read only) 
    如果你的应用程序只需读取一个持久化类的实例,而无需对其修改, 那么就可以对其进行只读 缓存。这是最简单,也是实用性最好的方法。甚至在集群中,它也能完美地运作。 <class name="eg.Immutable" mutable="false">
        <cache usage="read-only"/>
        ....
    </class>