2 Replies Latest reply on Nov 13, 2009 4:49 PM by Tony Brouwer

    PersistenceProvider @PostConstruct bug

    Tony Brouwer Newbie

      The PersistenceProvider class (package org.jboss.seam.persistence) has a method marked @PostConstruct:

         // @Create method not called on stateless components
         public void init()

      The @PostConstruct annotation is the wrong class:


      It should be:


      The Seam Component class, when constructing any component, looks for javax.annotation.PostConstruct annotation and will only execute methods with this annotation on post construct. The persistenceProvider component thus does not get its post construct method invoked. This is especially a problem in HibernatePersistenceProvider which extends PersistenceProvider and overrides the init() method.

         public void init()

      As a result, MySQL databases have problems with the Seam library since they require wildcard counts in place of multi-column counts (e.g. select count(a,b) from c does not work in MySQL).

      BTW are there docs for which annotation classes to use? It seems a bit of a dog's breakfast. e.g. @Create annotation comes from another package:


        • 1. Re: PersistenceProvider @PostConstruct bug
          Tony Brouwer Newbie

          I'm going to raise this as a bug when I get a minute. Also, here's my workaround:

          package org.open18.persistence;
          import javax.annotation.PostConstruct;
          import org.jboss.seam.ScopeType;
          import org.jboss.seam.annotations.Install;
          import org.jboss.seam.annotations.Name;
          import org.jboss.seam.annotations.Scope;
          import org.jboss.seam.annotations.intercept.BypassInterceptors;
          import org.jboss.seam.log.Log;
          import org.jboss.seam.log.Logging;
          import org.jboss.seam.persistence.HibernatePersistenceProvider;
           * Addresses problem with HibernatePersistenceProvider by explicitly
           * calling HibernatePersistenceProvider.init() from
           * a PostConstruct method that actually gets called on postconstruct.
          @Install(classDependencies={"org.hibernate.Session", "javax.persistence.EntityManager"})
          public class MoBetterHibernatePersistenceProvider extends HibernatePersistenceProvider {
              private static Log log = Logging.getLog(MoBetterHibernatePersistenceProvider.class);
              public void init()
                 log.debug("MoBetterPersistenceProvider init");

          • 2. Re: PersistenceProvider @PostConstruct bug
            Tony Brouwer Newbie

            Looks like this bug has recently been raised in JIRA: JBSEAM-4454