Announcement Announcement Module
Collapse
No announcement yet.
publishing PropertyChangeEvents with POJO using AOP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • publishing PropertyChangeEvents with POJO using AOP

    Hi,

    I have to enable my simple POJO's used with Spring/Hibernate to publish property changes. One way would be to use PropertyChangeSupport for the POJO's and do a firePropertyChange in every setter method.

    This is not the preferred way because there are a lot of classes to be changed.

    I found an interesting article about enabing this functionality in simple Java Beans using AOP (see http://www.damnhandy.com/?page_id=17).

    I wonder if someone has managed to implement a similar approach using Spring's configuration?

    Thanks and regards,

    Michael

  • #2
    Hi,

    I've found some interesting solutions for this in the ProSpring book, chapter 7 (the isModified example). With some modifications, this seems quite usable for me, except one point:

    The classes I want to add the property change functionality to are my model objects that are used by Hibernate to save and retrieve data.

    If I configure these objects via Spring configuration I can get them as advised beans through the application context, but if they are instantiated by Hibernate they don't have the Spring configuration and are not advised.

    I wonder how the Hibernate generated objects could be advised also in a Springy way?

    Any ideas?

    Thanks and regards,

    Michael

    Comment


    • #3
      "I wonder how the Hibernate generated objects could be advised also in a Springy way?"

      1. look for the first part of http://forum.springframework.org/showthread.php?t=18260.
      2. look at hibernate interceptor. it has a method where you could create the POJO's by using Sping bean factory.
      3. from spring SessionFactoryUtils JavaDoc:
      Supports setting a Session-level Hibernate entity interceptor that allows to inspect and change property values before writing to and reading from the database. Such an interceptor can also be set at the SessionFactory level (i.e. on LocalSessionFactoryBean), on HibernateTransactionManager, or on HibernateInterceptor/HibernateTemplate.
      Last edited by robyn; May 14th, 2006, 06:59 PM.

      Comment

      Working...
      X