9 Replies Latest reply on Dec 4, 2009 3:26 PM by Sharath Komarla

    using envers hbm2ddl with spring?

    Elhanan Maayan Novice

      hi.. is there a way to use envers hbm2dll with a spring configuration?
      i know that the regular hbm2ddl can be used with hibernate.properties and without cfg.xml is there a similar way with envers?

        • 1. Re: using envers hbm2ddl with spring?
          Adam Warski Master

          Hello,

          yes, please look in the documentation.

          Adam

          • 2. Re: using envers hbm2ddl with spring?
            Elhanan Maayan Novice

            i did, that's why i'm asking, it only states jpa/annotation/jdbconfiguration, is there anywhere else i can look?

            • 3. Re: using envers hbm2ddl with spring?
              Adam Warski Master

              Hello,

              ah ok. I don't know much about spring, so hard to say. You can use the EnversHibernateToolTask, if that's an option.

              Adam

              • 4. Re: using envers hbm2ddl with spring?
                Elhanan Maayan Novice

                the ant task what i was talking about, but if it requirest cfg.xml with a list of class mappings (or classes) then that's a problem, if i could just give it the class path it self. then what would be fine.
                (hey, i wish the cfg.xml itself would be able to auto detect entities, without the use of jpa)

                • 5. Re: using envers hbm2ddl with spring?
                  Adam Warski Master

                  Hello,

                  unfortunately there's nothing above the ant task, neither in Hibernate (AFAIK), nor in Envers.

                  Adam

                  • 6. Re: using envers hbm2ddl with spring?
                    Sharath Komarla Newbie

                    I don't know if this helps you or not.. but I have spring load hibernate cfg like this:

                    <bean id="sessionFactory"
                     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
                     <property name="dataSource" ref="dataSource"/>
                    
                     <property name="hibernateProperties">
                     <props>
                     <prop key="show_sql">true</prop>
                     <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                     <prop key="hibernate.cache.use_query_cache">true</prop>
                     <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
                     <prop key="hibernate.jdbc.use_scrollable_resultset">true</prop>
                     <prop key="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</prop>
                     <prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</prop>
                     </props>
                    
                     </property>
                     <property name="jtaTransactionManager">
                     <bean factory-bean="transactionManager" factory-method="getTransactionManager"/>
                     </property>
                     <property name="mappingLocations">
                     <value>classpath*:com/companyxyz/module/model/**/*.hbm.xml</value>
                     </property>
                     </bean>
                    


                    If this wasn't the question, then sorry for cluttering the thread

                    • 7. Re: using envers hbm2ddl with spring?
                      Elhanan Maayan Novice

                      actually this is how spring loads hibernate ... WITHOUT to use of cfg.xml :)

                      this is how we are using hibernate as well (only without the wild cards, spring xml is being re-generated automatically)

                      so, as fellow enver user (i'm guess this is why you are in this forum) how would you use the envers hbm2ddl task with your spring config?

                      • 8. Re: using envers hbm2ddl with spring?
                        Sharath Komarla Newbie

                        I haven't gotten that far :)

                        However for me, our data model is managed by a data architect, and thus would be managed manually. The other thing I would likely do, is create a target db, and let hibernate/envers create the envers tables at start time once, and then pull those changes into out erwin model

                        • 9. Re: using envers hbm2ddl with spring?
                          Sharath Komarla Newbie

                           

                          "Elhanan" wrote:
                          actually this is how spring loads hibernate ... WITHOUT to use of cfg.xml :)

                          this is how we are using hibernate as well (only without the wild cards, spring xml is being re-generated automatically)

                          so, as fellow enver user (i'm guess this is why you are in this forum) how would you use the envers hbm2ddl task with your spring config?


                          You could add
                          <prop key="hibernate.hbm2ddl.auto">update</prop>

                          to the hibernateProperties of the sessionFactory bean.

                          A side effect to this is that hibernate will try to update the db everytime it starts up. For me, this is an issue since hibernate the hbm has slight differences compared to the physical model and makes changes our DBA doesn't like.