I am using Hibernate events to try and write to a db each time a saveOrUpdate method is called. It is stepping into this event ok, however the object is not being saved to the db.
Code:
public class MyListener extends DefaultSaveOrUpdateEventListener
{
public void onSaveOrUpdate(SaveOrUpdateEvent aEvent) throws HibernateException
{
//code
Session session = aEvent.getSession().getSessionFactory().openSession();
session.save(myObject);
My hibernate config stuff.
Code:
<bean id="saveUpdateListener"
class="myCompany.data.MyListener" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="eventListeners">
<map>
<entry key="save-update">
<ref local="saveUpdateListener" />
</entry>
</map>
</property>
I have also tried in MyListener to get the session via:
Code:
Session session = aEvent.getSession();
That doesnt work either, any ideas why?