2 Replies Latest reply on Sep 27, 2011 4:24 PM by Adriano Saturno

    Multiple hibernate configuration files?

    Adriano Saturno Newbie

      First of all, I'm not using JPA.


      How can I have more than on configuration file?


      AnnotationConfigurationTaskWithEnvers.setConfigurationFile(configurationFile) works for one hibernate configuration file and

      AnnotationConfigurationTaskWithEnvers.addConfiguredFileSet(fileSet) doesn't work (fileset could be my congiguration files).


      I tried to get the Configuration from the AnnotationConfigurationTaskWithEnvers.getConfiguration and configure it manually, but it seems that the AnnotationConfigurationTaskWithEnvers should have the configuration files set before invoking this method.

        • 1. Re: Multiple hibernate configuration files?
          Adam Warski Master

          Or you can just do it manually:

          * first create the configuration

          * then call AuditConfiguration.getFor(configuration);

          * finally do the schema export


          Did you find out why the .addConfiguredFileSet doesn't work?



          • 2. Re: Multiple hibernate configuration files?
            Adriano Saturno Newbie

            We have to invoke configure() after involking addConfiguredFileSet(). But we can't do this, because we need to invoke getConfiguration() to get the configuration, and getConfiguration() do this:


                                if(cfg==null) {

                                          cfg = createConfiguration();


                                          cfg.buildMappings(); // needed otherwise not all assocations are made!


                                return cfg;


            at this time, cfg is null, but we have no configuration files.


            If we invoke configure() right after this, to use the configuration files, cfg is not null, so, doConfiguration is not called anymore.