1 Reply Latest reply on Sep 22, 2009 4:20 PM by Ales Justin

    How to specify a dependency on the hibernate session factory

    Russ Egan Newbie

      Using jboss 5.1. I have a @Service bean which is starting before the Hibernate SessionFactory is created and bound into JNDI. @Service bean uses an @Resource to inject the session factory, but that doesn't set up a dependency.

      I can't figure out how to specify the dependency. There doesn't seem to be any JMX bean which represents the Hibernate SessionFactory, so I don't know what to depend on.

      In fact, I went looking at other services which I thought might depend on Hibernate, like the ejb container, but I don't see any explicit dependency specified. It sort of looks like hibernate just coincidentally starts first in most cases. What am I missing? Thanks.

        • 1. Re: How to specify a dependency on the hibernate session fac
          Ales Justin Master

          You could do the following:
          (1) add JndiKernelRegistryPlugin bean to MC - this knows how to lookup jndi
          (2) add @Depends("my-hibernate-session-jndi-name") to your service bean

          This would create explicit dependency.

          But one note, (1) is then used at every MC lookup call, hence performance penalty
          + MC could find some other njdi entries you might not wanna expose (you could create your own version of JKRP, which would "fix" this).