我看了Configuration的源代码,构造函数里只调用了reset() protected void reset() {
classes = new HashMap();
collections = new HashMap();
tables = new HashMap();
namedQueries = new HashMap();
namedSqlQueries = new HashMap();
secondPasses = new ArrayList();
interceptor = EMPTY_INTERCEPTOR;
properties = Environment.getProperties();
}
是不是最后一行的properties = Environment.getProperties()有问题??

解决方案 »

  1.   

    把hibernate的sessionfactory部署成jndi方式,要不然同时使用ejb和hibernate会有冲突,好像是这样!
      

  2.   

    我看到的把hibernate的sessionfactory部署成jndi方式的原因是:In most Hibernate applications, the SessionFactory should be instantiated once
    during application initialization. The single instance should then be used by all
    code in a particular process, and any Sessions should be created using this single
    SessionFactory. A frequently asked question is where this factory must be placed
    and how it can be accessed without much hassle.
    In a J2EE environment, a SessionFactory bound to JNDI is easily shared between
    different threads and between various Hibernate-aware components.上面的文字出自Hibernate in action,但是其中没有提到ejb和hibernate会有冲突?为什么会有冲突呢?
      

  3.   

    如果你不把hibernate交给容器管理,而自己管理得话,到了EJB中调用hibernate得时候,事务处理就会有冲突,不知道是hibernate自己管理还是weblogic管理.
    还有每一次建立sessionfatory是非常耗资源得,而建立session耗费资源就来得小的多,所以当你绑定到jndi得时候,效率也会高点.
      

  4.   

    ejb的事務類型要設為<transaction-type>Bean</transaction-type>
    確實用jndi好像會好一些,關於配置hibernate,我也不是很明白
    你看看是不是因爲這個錯誤