Announcement Announcement Module
Collapse
No announcement yet.
Hibernate DefaultLoadEventListener; how to configure? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate DefaultLoadEventListener; how to configure?

    Hi there,

    Spring is fantastic. I love it.

    For my first ever post here, I need to ask for help in configuring my subclass of Hibernate3's DefaultLoadEventListener.

    From Hibernate's 3 doco:

    Code:
    <hibernate-configuration>
        <session-factory>
            ...
            <listener type="load" class="MyLoadListener"/>
        </session-factory>
    </hibernate-configuration>
    And I'm trying to figure out how to place this in my applicationContext.xml:

    Code:
      <!-- Hibernate SessionFactory -->
       
       <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    
          <property name="dataSource">
             <ref local="dataSource"/>
          </property>
          
    <property name="hibernateProperties">
             <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
                <prop key="hibernate.use_outer_join">true</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>  
                <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>  
                <prop key="hibernate.max_fetch_depth">3</prop>  
                <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>  
             </props>
             
             
          </property>
          
          <listener type="load" class="com.cybera.seneca.persistence.audit.event.LoadListener"/>
          
       </bean>

    Would anyone provide a quick example of how to configure this? Thanks.

  • #2
    [Hibernate DefaultLoadEventListener; how to configure?] ....

    Did anyone find the solution to this?

    Thanks, J

    Comment


    • #3
      Read the javadocs for LocalSessionFactoryBean :
      void setEventListeners(Map eventListeners)
      Specify the Hibernate event listeners to register, with listener types as keys and listener objects as values.
      Even better - check out the samples within the Spring distribution.

      The xml should be something like:
      Code:
      <property name="eventListeners">
        <map>
           <entry key="load"><bean class="your.class.here"/></entry>
        </map>
      </property>
      P.S. I haven't configured any listeners until now - I just wrote this on the fly just by reading the docs.

      Comment

      Working...
      X