aspose file tools*
The moose likes Spring and the fly likes Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml" Watch "Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml" New topic
Author

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

Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
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

Joined: Aug 31, 2010
Posts: 16
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
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

Joined: Feb 05, 2001
Posts: 17250
    
    6

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.
 
subject: Problem about :Config the EventListener (org.hibernate.event) in ApplicationContext.xml