<p>Is it possible to define a spring-managed EJB3 hibernate listener?</p>

<p>I have this definition in my <strong>persistence.xml</strong>:</p>

<pre><code>&lt;properties&gt; 
    &lt;property name="hibernate.ejb.interceptor"
        value="my.class.HibernateAuditInterceptor" /&gt; 
    &lt;property name="hibernate.ejb.event.post-update"
        value="my.class.HibernateAuditTrailEventListener" /&gt; 
&lt;/properties&gt;
</code></pre>

<p>But I would like to manage <code>HibernateAuditInterceptor</code> and <code>HibernateAuditTrailEventListener</code> with spring, so I can do some bean injection (ex: session-scoped bean) within these classes. Is this possible?</p>

The problem is that those properties are just strings. Even if you define your SessionFactory as a Spring bean, any properties you pass to it through the hibernateProperties setter are just strings:
```
```
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource"ref="myDataSource"/>
    <property name="mappingResources">
        <list>
            <value>whatever.hbm.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <value>
            hibernate.ejb.interceptor= my.class.HibernateAuditInterceptor
        </value>
        <value>
            hibernate.ejb.event.post-update=my.class.HibernateAuditTrailEventListener
        </value>
    </property>
</bean>
```
```
So I don't think you can do that.