Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ivy chen
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
  • 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~
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic