Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my practise,i want to persist some information about Hibernate Event into the dataBase by Spring.

And i configed the Hibernate Event Listener (Such as:PostInsertEventListener) in the ApplicationContext.

How ever problems occur.

Here are the Exceptions out print in MyEclipse:





Here are my beans and ApplicationContext.xml

HibernateEventListener( which is a table to save the information )


PostInsertEvent(get the information of the Insert Action )


HibernateEventListenerDaoImpl (save the event information into the dataBase)


ApplicationContext.xml,I thing the problems occur in the tag:<property name="eventListeners">( in line 30)




hunger for your answer,Thanks~







 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i just use Hibernate ( without Spring ) , i can define these listeners in the hibernate.cfg.xml, and every thing goes well.

i need your help~

IVY~
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While I am not sure if LocalSessionFactoryBean has a property called eventListeners.

It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.

SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory

See how the references/dependencies work its way back to the SessionFactory.

Mark
 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:While I am not sure if LocalSessionFactoryBean has a property called eventListeners.

It looks to me like you have a circular reference going on here and Spring can't figure out which comes first, the Chicken or the Egg.

SessionFactory --- EventListeners -- EventListener -- EventListernerDAO -- SessionFactory

See how the references/dependencies work its way back to the SessionFactory.

Mark



As you say,when i config the "Hibernate EventListener" in the Spring,i found there was a circular between the sessionFactory and the Listeners(obviously this configaration is unreasonable and make me confused).

Dear Mark:
Is there any way that i can config the "Hibernate EventListener" in the Spring?
1/use an MethodInterceptor in a aspect??
2/config the "Hibernate EventListener" in the "hibernate.cfg.xml"??
3/or any other better ways???

Waiting for your guidance.....thanks~
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about using annotations in your classes for @PreUpdate etc from Hibernate.

http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html_single/#listeners

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic