最主要的是修改了配置文件如何让hibernate动态加载,而不需要重启数据库。

解决方案 »

  1.   

    Configuration cfg = new Configuration()
        .addResource("Item.hbm.xml")
        .addResource("Bid.hbm.xml");
    另外再看看hibernate文档的第5章 5.4. 动态模型(Dynamic models)
      

  2.   

    BCEL 是可以动态在内存中创建class的。The Byte Code Engineering Library is intended to give users a convenient possibility to analyze, create, and manipulate (binary) Java class files (those ending with .class). Classes are represented by objects which contain all the symbolic information of the given class: methods, fields and byte code instructions, in particular.
      

  3.   

    动态创建class的第三方包很多压,比如:javasist,asm,等,使用sun的标准包也可以在程序里将一个java文件编译成class文件,
      

  4.   

    reflection也可以帮你完成!推荐CGLIB工具
      

  5.   

    javaeye的人每天就在那里吹牛,其实稍微看一下hibernate的源代码就知道该怎么做了。net.sf.hibernate.cfg.Configurationpublic Configuration configure(File configFile)
                            throws HibernateExceptionpublic Configuration addFile(File xmlFile)
                          throws MappingException用文件的绝对路径,保证每次获得的是文件的最新内容就可以动态修改内存中的o/r映射。
    他内部维护一堆Map和List,所以会把旧内容覆盖。
    但是,不会删除已加载的关联(xxx-to-xxx)等,这个还没测试过有多少影响。
    需要扩展出一堆removeXXX的方法来做对应的动作。
      

  6.   

    hibernate就是用的CGLIB,所以动态生成类的功能已写好。
      

  7.   

    不是说他们不厉害,只是感觉他们很倚老卖老。
    他们经常说“这个东西我在xx项目这样...使用”,很少看到“这个东西实现方式是...所以我们这样...会比较好”。只有应用没有研究,缺乏深度。这点javaresearch比他们强。
      

  8.   

    cm4ever真牛啊,"其实稍微看一下hibernate的源代码就知道该怎么做了。"