4 Replies Latest reply on Nov 19, 2008 6:48 AM by corneil

    Need a QuickStart for Spring + Hibernate

    vbforums

      Hi Adam,

      Thanks for developing Envers, the great way for Entity Versioning.

      I need couple of help from you

      1. Can you please post a QuickStart guide for Spring + Hibernate users. Currently I am not sure where to inject your beans.

      2. What will be the supporting Jars needed for Envers to work, Do I need to have the hibernate-entity manager jar for Envers to work

      Your help on this is much appreciated.

      Thanks,
      vbforums

        • 1. Re: Need a QuickStart for Spring + Hibernate
          adamw

          Hello,

          I never used Spring, but if anybody would like to contribute such a guide, I'll post it on the website :)

          Concerning the JARs, you'll need hibernate entity manager, as it's a dependency of the VersionsReaderFactory. I guess it would be better if there were separate factories for pure hibernate and jpa-hibernate, so that you wouldn't have always to bundle hibernate entity manager when not using it.

          And if you don't user JPA, then I guess you'll need hibernate annotations :).

          Adam

          • 2. Re: Need a QuickStart for Spring + Hibernate
            vbforums

            Hi Adam,

            Thanks for your response.

            1. Can you please let me know the primary class name which I need to instantiate and is this an Hibernate Event listener or interceptor.

            3. Will Envers work in WLS environment.

            Thanks,
            vbforums

            • 3. Re: Need a QuickStart for Spring + Hibernate
              adamw

              Hello,

              you don't instantiate anything, you just need to use VersionsReaderFactory. Please see the quickstart: https://www.jboss.org/envers/quickstart.html.

              Envers will work wherever Hibernate works, so also in a WLS environment.

              Adam

              • 4. Re: Need a QuickStart for Spring + Hibernate
                corneil

                Envers does not need anything more than you would use to get Hibernate EntityManager and Spring working.
                I use JpaTemplate and JpaDaoSupport so you would use like:

                getJpaTemplate().execute(new JpaCallback() {
                 public Object doInJpa(EntityManager em) throws PersistenceException {
                 VersionsReader reader = VersionsReaderFactory.get(em);
                 // your code here
                 }
                }